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

删除回忆录丶 提交于 2019-11-29 04:07:17

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.

Pax

There is actually no "Item" property in C#. In VB the DataRow cell access is defined like this:

Default Public Property Item (
    column As DataColumn
) As Object

So there is a literal "Item" property. However, in C# it is defined like this:

public object this[
    DataColumn column
] { get; set; }

So this is the default property of the class / object. So you access it with the object name.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!