C# Datatable - how to extract a specific value

Hi All

I have a C# datatable populated by a SQL statment.

Say the datatable has returned a 100 records and there are five coloumn headers, how do I just display record 50, coloumn 2 from the datatable

I'd guess something like Console.Write(MyDatatable.rows[50].Coloumns[2])

but it's just not happening
MrDavidThornAsked:
Who is Participating?
 
Jens FiedererConnect With a Mentor Test Developer/ValidatorCommented:
like
MyDatatable.Rows[50].ItemArray[2]
0
 
Jens FiedererTest Developer/ValidatorCommented:
You can access a row's ItemArray
0
 
dustockCommented:
Its going to be base 0 so you'll want this.

MyDataTable.Rows[49].ItemArray[1].ToString();

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.