我有一个锯齿阵列的双打,我需要将其转换为可以添加到xml文档中的东西,然后再转回锯齿状阵列。任何人都知道如何做到这一点?提前致谢。如何将锯齿形双数组转换为字符串并返回?
public double[][] Coordinates { get; set; }
//For context this is how I'm creating the array
//convert the geography column back in lat\long points
for (var g = 1; g <= geography.STNumGeometries(); g++)
{
var geo = geography.STGeometryN(g);
var points = new List<double[]>();
for (var i = 1; i <= geo.STNumPoints(); i++)
{
var point = new double[2];
var sp = geography.STPointN(i);
// we can safely round the lat/long to 5 decimal places
// as thats 1.11m at equator, reduces data transfered to client
point[0] = Math.Round((double) sp.Lat, 5);
point[1] = Math.Round((double) sp.Long, 5);
points.Add(point);
}
transitLineSegment.Coordinates = points.ToArray();
}
你有什么要求?应该是“XMLy”吗?是整个阵列的一个字符串好吗?它应该是人类可读的吗?结果的大小有多重要? – svick
@svick不一定是XMLy。我更喜欢东西是一个字符串,因为它将在另一个XML文档中。没有关系,如果它是人类可读的。大小无关紧要。 – NullReference