日期:2014-05-18  浏览次数:20402 次

如何判断数据类型
怎样使用循环去判断 table 中的每一列的数据是否为 byte[]

DataTable table = new DataTable();
 foreach (DataColumn colSource in _myDataSet.Tables[0].Columns)
{
  if (判断语句)//请教大虾
  {
  dtData.Columns.Add(new DataColumn(colSource.ColumnName, typeof(string)));
  }

------解决方案--------------------

if (colSource.DataType == System.Type.GetType("System.Byte"))//请教大虾
{
dtData.Columns.Add(new DataColumn(colSource.ColumnName, typeof(string)));
}
参考:http://msdn.microsoft.com/en-us/library/system.data.datacolumn.datatype.aspx
------解决方案--------------------
C# code
        DataTable table = new DataTable();
        foreach(DataColumn column in table.Columns)
            if(column.DataType==typeof(byte[]))
                //添加