【发布时间】:2011-09-25 04:24:45
【问题描述】:
我在我的 asp.net mvc 3 应用程序中实现了一个简单的扩展方法,以使用泛型将对象拉出会话:
public static T GetVal<T>(this HttpSessionStateBase Session, string key, Func<T> getValues)
{
if (Session[key] == null)
Session[key] = getValues();
return (T)Session[key];
}
如果 getValues() 不需要任何参数,这将非常有用。
我试图编写一个接收 params object[] args 的重载,以允许我在必要时将参数传递给 getValues() 函数,但我不知道语法是什么将这些变量应用于函数。
这甚至可能吗?提前感谢您的建议。
【问题讨论】:
标签: c# .net asp.net-mvc-3 delegates arguments