C# 给DataTable 里面的某一个字段控制字符串的长度输出。

 1 public static DataTable SubstringTites(DataTable oDT)
 2 {
 3 DataTable NewTable = oDT.Clone();
 4 foreach (DataRow item in oDT.Rows)
 5 {
 6 if (item["Title"].ToString().Length >= 30)
 7 {
 8 item["Title"] = item["Title"].ToString().Substring(0, 30) + "...";
 9 }
10 NewTable.ImportRow(item);
11 }
12 return NewTable;
13 }

 

posted @ 2018-08-23 11:02  低调攻城狮  阅读(1360)  评论(0编辑  收藏  举报