In C#: Why no 'Item' on System.Data.DataRow?

后端 未结 2 2151
难免孤独
难免孤独 2020-12-16 20:54

I\'m rewriting/converting some VB-Code:

Dim dt As New System.Data.DataTable()
Dim dr As System.Data.DataRow = dt.NewRow()
Dim item = dr.Item(\"myItem\")
         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-16 21:33

    Try like this:

    var item = dr["myItem"];
    

    In C# you can access the indexer property directly. And the DataRow.Item property is defined as indexer.

提交回复
热议问题