开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜