2012-08-27

DataRow keeps converting values into strings

when i use DataRow.ItemArray or the DataRow's indexer (eg myDataRow[0] = ...) to set the values to objects, the values are converted to strings.

DataRow row = ...;
row[0] = (object)5;

//problem:
//row[0] == "5"
//row[0] != 5

the solution is to specify the type on the DataTable's column.

DataTable t = ...;
t.Columns[0].DataType = typeof(object);

No comments:

Post a Comment