【发布时间】:2009-04-08 15:15:05
【问题描述】:
为什么会编译:
public Dictionary<ValueLineType,
Func<HtmlHelper,
string,
object,
Type,
string>> constructor =
new Dictionary<ValueLineType,
Func<HtmlHelper,
string,
object,
Type,
string>>();
但不是在 Func(布尔值)中有一个额外参数的另一个:
public Dictionary<ValueLineType,
Func<HtmlHelper,
string,
object,
Type,
bool,
string>> constructor =
new Dictionary<ValueLineType,
Func<HtmlHelper,
string,
object,
Type,
bool,
string>>();
要么我失明了,要么我今天要学习其他东西:D
【问题讨论】:
-
顺便说一下,第二行的错误是:“Using the generic type 'System.Func
' requires '2' type arguments” -
顺便说一句,'var' 关键字是你的新朋友。见msdn.microsoft.com/en-us/library/bb383973.aspx 和stackoverflow.com/questions/9033#9035。
-
绝对比写两次要好得多!
标签: c# dictionary lambda