Bla*_*ter 5 c# datatable decimal
我有这个代码来向数据表添加新列:
DataColumn col = new DataColumn("column", typeof(decimal));
col.Caption = "列";
mytable.Columns.Add(col);
如何为此列指定小数精度,以便该值始终采用我想要的格式?
你不能。但是,您可以在使用函数从表中检索值时格式化该值String.Format:
String.Format("{0:0.##}", (Decimal) myTable.Rows[rowIndex].Columns[columnIndex]);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21956 次 |
| 最近记录: |