Get the Column Type of Data Table in C#

You can get the column data type of the data table easily. There are just two lines of code, that will help you find the data type.

/* dt is the object of datatable . */
System.Type type = dt.Rows[0][1].GetType();
if (type == typeof(string))
{
     dt.Rows[0][1] = "Data type is string";
}
Ebook Download
View all
Learn
View all