c# - how to check if a column exist in a datatable -


i have datable generated content of csv file. use other information map column of csv (now in datatable) information user required fill.

in best world mapping alway possible. not reality... before try map datatable column value need check if column exist. if don't check have argumentexception.

of course can check code :

try {     //try map here. } catch (argumentexception) { } 

but have 3 columns map , or might existing/missing

is there way check if column exist in datatable?

you can use operator contains,

private void containcolumn(string columnname, datatable table) {     datacolumncollection columns = table.columns;             if (columns.contains(columnname))     {        ....     } } 

msdn - datacolumncollection.contains()


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -