tags:

views:

166

answers:

2

Hi, I have seen this piece of code in an example via online using C#

DataTable dt = ds.Tables["employees"];

dt.Rows[0]["city"] = "Wilmington";

My question is what is the zero stands for? is it an ordinal index or not?

Thanks in advance!

+2  A: 

0 references to the first row of the datatable. (zero-based counting)

ammoQ
+2  A: 

Look up DataTable on MSDN and check out the property Rows. It returns an instance of DataRowCollection.

It's not clear by the documentation, but non-array types can also implement the [] indexer. The DataRowCollection implements [int index] where index is the row to return. The collection can thus be accessed in the same manner as with an array, with the exception that this is a method call. It's for example not possible to pass return values from indexing methods as reference parameters.

John Leidegren