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

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.


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.

Tags:

C#

System.Data