c#中结构数组怎么定义
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;
//...
}
//类数组
Class RGB
{
public byte red;
public byte green;
public byte blue;
public RGB(byte r,byte g,byte b)
{
this.red = r;
this.green = g;
this.blue = b;
}
}
//以上定义了形如实体类一样的一个类
//类数组在使用的时候需要注意的是:必须要实例化
Class Test
{
RGB[] rgb = newRGB[image.width*image.height];
byte red,green,blue;
rgb[0] = newRGB(red,green,blue);
rgb[1].red = red;
rgb[1].green = green;
rgb[1].blue = blue;
rgb[2].red = red;
//...
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询