point保存到数据库的一个小问题

.Net技术 码拜 9年前 (2016-03-04) 821次浏览
首先用 Point p = new Point();然后分别定义它的p,X和p.Y,最后将它保存到StringBuilder中,显示为(1,1)(1,2);
问题是
List<Point> p = new List<Point>();
listpoint.Add(new Point(Convert.ToInt32(i ), Convert.ToInt32(j )));
sb.Append(p);结果显示的却是System.Collections.Generic.List`1[System.Drawing.Point],用List<>怎么才能显示成(1,2)的形式呢?求指导point保存到数据库的一个小问题
解决方案

20

写法之一

foreach(var x in p.Select(t => "(" + t.X + "," + t.Y + ")"))
{
  sb.Append(x);
}

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明point保存到数据库的一个小问题
喜欢 (0)
[1034331897@qq.com]
分享 (0)