Setting the size of char datacolumn
I would like add new column 开发者_开发问答to my datatable. The column is of type char with length of 10.
DataColumn d = new DataColumn(fieldname, typeof(char)); dt.Columns.Add(d);
My Question is how do I add "size" to this column?
Thanks a lot.
Note that in C#, a char
is always one character. Try this:
DataColumn d = new DataColumn(fieldname, typeof(string));
d.MaxLength = 10;
dt.Columns.Add(d);
精彩评论