我有一個鋸齒陣列的雙打,我需要將其轉換爲可以添加到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