In this article, we will learn how to check if the specified column name exists in the DataTable
in C# or Not.
Here is the source code of the program to check whether the specific column exists in the DataTable or not.
private bool isColumnExists(string columnName, DataTable table)
{
bool columnExists = false;
DataColumnCollection columns = table.Columns;
if (columns.Contains(columnName))
{
columnExists = true;
}
return columnExists;
}
I hope this article will help you to understand how to check if the specified column name exists in the DataTable in C# or Not.
Share your valuable feedback, please post your comment at the bottom of this article. Thank you!
Comments