1
Answer

Efficient way to validate data of DataTable

Ravindra Sawant

Ravindra Sawant

11y
3.5k
1
I have following DataTable (dataTable)

**ColumnName**  :   **Data**  
IDS : System.String  
QTY : System.Int32  
DOS      System.DateTime  


and following dictionary

Dictionary<string,Type> dict=new Dictionary<string, Type>();
dict["ID"]=typeof(string);
dict["QTY"]=typeof(Int32);
dict["DOS"]=typeof(DateTime);


Using following method for validating data of dataTable


public void ValidateData(Dictionary<string, Type> dict, DataTable dataTable)
{
foreach (DataRow row in dataTable.Rows)
{
// validate data here
}
}


What is best/efficient way to validate data here.

Thanks.

Answers (1)