Hi, just refer this code,
public bool CheckColumns(DataTable objTable, string[] columns)
{
bool IsAllCoumnsExists = false;
List<string> ColumnList = new List<string>();
foreach (DataColumn objColumn in objTable.Columns)
{
ColumnList.Add(objColumn.ColumnName);
}
foreach (string column in columns)
{
bool temp = ColumnList.Contains(column);
if (temp == true)
{
IsAllCoumnsExists = true;
}
else if (temp == false)
{
IsAllCoumnsExists = false;
break;
}
}
return IsAllCoumnsExists;
}
This code checks all whether all columns are exists in datatable or not.