C#结构问题

来源:百度知道 编辑:UC知道 时间:2024/06/17 13:29:53
我定义了一个结构
struct student
{
public int score ;
}
通过这个结构我想写入3个学生的成绩分别为70,80,90
怎么写入
要用什么语句
怎么写
帮个忙吧

定义一个结构数组。我现在没环境随便写一下。等你使用的时候遍历出来就OK了。
struct student
{
public string stuName;
public double stuScore;
}
public student[] stuResule()
{
student[0].stuName="张三";
student[0].stuScore=70;
.......
}

struct student
{
public int score;
}

private void button1_Click(object sender, System.EventArgs e)
{
student st1,st2,st3;
st1.score=50;
st2.score=70;
st3.score=80;
MessageBox.Show("value="+st1.score.ToString());

}

需要声明三个此结构类型的变量,然后再依次赋值