Use of C# var for implicit typing of System.Data.Datarow

前端 未结 2 1513
孤城傲影
孤城傲影 2021-02-12 18:31
foreach (var row in table.Rows)
{
     DoSomethingWith(row);
}

Assuming that I\'m working with a standard System.Data.DataTable (which has

2条回答
  •  礼貌的吻别
    2021-02-12 19:25

    An implicit cast happens. Also note that an InvalidCastException can be thrown if the cast isn't possible.

提交回复
热议问题