PublicDataTable Makedatatable () {DataTable myTable; DataRow Mynewrow; //Create a new DataTable.MyTable =NewDataTable ("My Table"); //Create DataColumn objects of data types.DataColumn colstring =NewDataColumn ("Stringcol"); Colstring.datatype= System.Type.GetType ("System.String"); MYTABLE.COLUMNS.ADD (colstring); DataColumn ColInt32=NewDataColumn ("Int32col"); Colint32.datatype= System.Type.GetType ("System.Int32"); MYTABLE.COLUMNS.ADD (ColInt32); DataColumn Colboolean=NewDataColumn ("Booleancol"); Colboolean.datatype= System.Type.GetType ("System.Boolean"); MYTABLE.COLUMNS.ADD (Colboolean); DataColumn Coltimespan=NewDataColumn ("Timespancol"); Coltimespan.datatype= System.Type.GetType ("System.TimeSpan"); MYTABLE.COLUMNS.ADD (Coltimespan); DataColumn Coldatetime=NewDataColumn ("Datetimecol"); Coldatetime.datatype= System.Type.GetType ("System.DateTime"); MYTABLE.COLUMNS.ADD (Coldatetime); DataColumn Coldecimal=NewDataColumn ("Decimalcol"); Coldecimal.datatype= System.Type.GetType ("System.Decimal"); MYTABLE.COLUMNS.ADD (Coldecimal); DataColumn Colbytearray=NewDataColumn ("Bytearraycol"); Colbytearray.datatype= System.Type.GetType ("system.byte[]"); MYTABLE.COLUMNS.ADD (Colbytearray); //Populate one row with values.Mynewrow =Mytable.newrow (); mynewrow["Stringcol"] ="Item Name"; mynewrow["Int32col"] =2147483647; mynewrow["Booleancol"] =true; mynewrow["Timespancol"] =NewTimeSpan (Ten, A,Ten, the, -); mynewrow["Datetimecol"] =System.DateTime.Today; mynewrow["Decimalcol"] =64.0021; mynewrow["Bytearraycol"] =NewByte[] {1,5, - }; MYTABLE.ROWS.ADD (Mynewrow); returnmyTable; }
. Net-datacolumn.datatype Property