G
Guest
I have a DataSet/DataTable read in from an XML file. I can loop through the
DataRows in the DataTable, and do actions like this:
string theName = dr["Name"].ToString();
My fear is that somebody is going to come along and slightly change the xml
file, perhaps changing "Name" to "Names". The rather brittle line above will
throw an exception.
I'd really like to do something like the following:
if(dr["Name"].Exists)
string theName = dr["Name"].ToString();
As far as I can tell, the .Exists doesn't exist in this context in C#.
Any suggestions on how to approach this, other than just catching the
exception?
Thanks,
DataRows in the DataTable, and do actions like this:
string theName = dr["Name"].ToString();
My fear is that somebody is going to come along and slightly change the xml
file, perhaps changing "Name" to "Names". The rather brittle line above will
throw an exception.
I'd really like to do something like the following:
if(dr["Name"].Exists)
string theName = dr["Name"].ToString();
As far as I can tell, the .Exists doesn't exist in this context in C#.
Any suggestions on how to approach this, other than just catching the
exception?
Thanks,