How do you use Func<> and Action<> when designing applications?

后端 未结 9 977
情书的邮戳
情书的邮戳 2020-12-22 16:27

All the examples I can find about Func<> and Action<> are simple as in the one below where you see how they technically work but I would like

9条回答
  •  旧时难觅i
    2020-12-22 17:29

    Actually, i found this at stackoverflow (at least - the idea):

    public static T Get  
        (string cacheKey, HttpContextBase context, Func getItemCallback)
                where T : class
    {
        T item = Get(cacheKey, context);
        if (item == null) {
            item = getItemCallback();
            context.Cache.Insert(cacheKey, item);
        }
    
        return item;
    }
    

提交回复
热议问题