Q:由于这些点的个数是不定的,所以在从文件里读的时候,也不能开数据来保存
A:你可以用(如)ArrayList 来存放不定个数的数据
请参考http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionsarraylistclasstopic.asp
A:你可以用(如)ArrayList 来存放不定个数的数据
请参考http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionsarraylistclasstopic.asp
ArrayList myAL = new ArrayList();
myAL.Add("Hello");
myAL.Add("World");
myAL.Add("!");
这个只是把字符串存进去啊...
public class dotpoint
{
//
private int _x;
private int _y;
private int _z;
//
public int X
{
get {return this._x;}
set {this._x=value;}
}
public int Y
{
get {return this._y;}
set {this._y=value;}
}
public int Z
{
get {return this._z;}
set {this._z=value;}
}}
定义一个对象,这个对象就是一个POINT
public struct Point
{
public int x, y,z;
public Point(int p1, int p2, int p3)
{
x = p1;
y = p2;
z = p3;
}
}
然后把这些结构存进ArrayList中,
myAL.Add(Point1);
myAL.Add(Point2);
你再使用的时候,
Point p1 = (Point)ArrayList1[0];
然后p1.x就可以用了.