DataRow[] dr = dt.Select("ID= 1");
foreach(DataRow row in dr)
{
var name = row["NAME"].ToString();
var contact = row["CONTACT"].ToString();
}
Using the 'Field extension method in System.Data, we can make simpler the casting of Column values from 'object to their native Type:
DataRow[] dr = dt.Select("ID= 1");
foreach(DataRow row in dr)
{
string name = row.Field<string>("NAME");
string contact = row.Field<string>("CONTACT");
}
You really need to review the "basics" of using a DataTable: [
^], [
^].