可能重复:
直接转换与“as”运算符?
谁能说出代码片段之间的实际区别?
var unknown = (object)new List<string>();
// Snippet 1: as operator
foreach (var item in unknown as IList<int>) {
// Do something with item
}
// Snippet 2: cast operator
foreach (var item in (IList<int>)unknown) {
// Do something with item
}