DataTable yourDataTable = new DataTable();
var result = yourDataTable.AsEnumerable()
.Take(2) // Select first two rows
.Select(r =>
new
{
Field1 = r.Field<int>("col1"), // Select your columns
Field2 = r.Field<string>("col2")
// your rest of the columns
}
);
If you want to select only the second row then:
var result = yourDataTable.AsEnumerable()
.Skip(1) // skip first row
.Take(1) // Select second row
.Select(r =>
new
{
Field1 = r.Field<int>("col1"), // Select your columns
Field2 = r.Field<string>("col2")
// your rest of the columns
}
);
EDIT:
To Select all columns, instead of specific one, just remove the Select from the statement. Something like this:
var result = yourDataTable.AsEnumerable()
.Skip(1) // skip first row
.Take(1); // Select second row