我必須寫的內容在此格式在foreach循環運行的for循環
somename1 value1 value2 value1 value2 ....
somename2 value1 value2 value1 value2 ....
somename3 value1 value2 value1 value2 ....
somename4 value1 value2 value1 value2 ....
somename5 value1 value2 value1 value2 ....
VALUE1和value2是一個點的x和y座標的一部分,所以這個我有創建了一個類:
class Points
{
string name;
double[] X;
double[] Y;
}
class PointsCollection
{
List<Points> aPoints
}
//now when accessing the PointCollection
foreach(Points aPoints in PointsCollection)
{
stream.Write(aPoints.Name)
//now i have to write the value1 and valud2
}
possible code
//now when accessing the PointCollection
foreach(Points aPoints in PointsCollection)
{
stream.Write(aPoints.Name)
int length1 = aPoints.Real;
int length2 = aPoints.Imag;
for(int i = 0 ; i < length1; i++)
{
stream.Write(aPoints.Real[i]);
stream.Write(",");
stream.Write(aPoints.Imag[i]);
}
stream.WriteLine();
}
問題:在foreachloop中使用循環是否正確?
可能會將內部循環移動到不同的方法,使它看起來整齊。 – Zenwalker 2012-04-27 07:59:12