在C#中如何定义坐标数组,怎样赋值?又如何使用?

比如 for (int i = 0; i <18; i++)
{
x1 = x + Convert.ToInt32(d * Math.Cos(3.14*i/9));
y1 = y + Convert.ToInt32(d * Math.Sin(3.14*i/9));
Point []a = {new Point(x1,y1)};
}意思是把x1,y1的坐标放到坐标数组中来,这样对不对?如果对,那是怎么样访问这个数组呢?如果不对,那又是怎么样呢?求指导~~~!!!~~~

我来举个例子给你
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool b = true;
static int m =0, n = 80;
private void Form1_Paint(object sender, PaintEventArgs e)
{
if (b)
{
int x = 240, y = 120, k=0,d = 100, x1, y1;

Point[] a = new Point[18];
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Red, 1);
p.DashStyle = DashStyle.Solid;
for (int i = 0; i < 18; i++)
{
x1 = x + Convert.ToInt32(d * Math.Cos(3.14 * i / 9));
y1 = y + Convert.ToInt32(d * Math.Sin(3.14 * i / 9));
a[i] = new Point(x1, y1);
}
for (int i = 0; i < 18; i++)
for (int j = i; j < 18; j++)
{
k++;
p.Color = Color.FromArgb(k+3, m, k+n);
g.DrawLine(p, a[i], a[j]);
}
}
这个是画一个18边形,没两点都连接的图来的,其中就用到了坐标数组,慢慢看,不懂再问···
温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-01-10
1.下面是定义一个结构体
struct HSI
{
public int hue;
public int saturation;
public int intensity;
}
Class Test2
{
HSI[] hsi = new HSI[image.width*image.height];
int hue;
int saturation;
int intensity;
hsi[0].hue = hue;
hsi[0].saturation = saturation;
hsi[0].intensity = intensity;
hsi[1].hue = hue;
//这样使用结构数组
}本回答被网友采纳
第2个回答  2013-05-16
double [] x;
double [] y;
相似回答