问一个DataTable 写入XML文件的问题
一个DataTable其中一列是bool类型,将其写入XML文件后在读出,
该列变成了字符串类型,ture -> "true " ; false -> "false "
如何才能控制该列其读出也为bool类型?(不要遍历赋值)
代码如下:
DataTable tab = new DataTable( "ResistInfo ");
tab.Columns.Add( "Check ", typeof(bool));
tab.Columns.Add( "Name ", typeof(string));
DataRow row = tab.NewRow();
row[ "Check "] = true;
row[ "Name "] = "ggg ";
tab.Rows.Add(row);
row = tab.NewRow();
row[ "Check "] = false;
row[ "Name "] = "fffff ";
tab.Rows.Add(row);
tab.WriteXml( "regeist.xml ");
DataSet newSet = new DataSet();
newSet.ReadXml( "regeist.xml ");
------解决方案--------------------DataTable redTable = tab.Clone();
redTable.ReadXml( "regeist.xml ");
-------------------------------------------
+ redTable.Columns[0].DataType {Name = "Boolean " FullName = "System.Boolean "} System.Type {System.RuntimeType}