【发布时间】:2011-09-19 08:20:18
【问题描述】:
我有以下 LINQ 表达式:
var ageEntry = from entry in args
where (entry.Key == "Age")
select entry.Value;
//I want age as Int16:
Int16 age = Convert.ToInt16(ageEntry);
但是我得到以下异常:
无法转换类型的对象 'WhereSelectEnumerableIterator
2[System.Collections.Generic.KeyValuePair2[System.String,System.String],System.String]' 输入“System.IConvertible”。
这不是我见过的最明显的例外,有人可以向我解释一下吗?
【问题讨论】: