C# 定义结构类型(有学号,姓名,性别和程序设计成绩四个字段),声明该结构类型变量,用赋值语句对此

C# 定义结构类型(有学号,姓名,性别和程序设计成绩四个字段),声明该结构类型变量,用赋值语句对此赋值以后再输出

struct Student
{
private string sno;
private string sname;
private char sex;
private float score;
public Student(string sno, string sname, char sex, float score)
{
this.sno = sno;
this.sname = sname;
this.sex = sex;
this.score=score;
}
public String SNo
{ get; }
public Char Sname
{ get; }
public String Sex
{ get; }
public Float Score
{ get; }
}

static void Main(string[] args)
{

Student s1 = new Student("201610236", "小明", 'M', 97.6);
Console.WriteLine("{0}-{1}-{2}-{3}",s1.SNo,s1.Sname,s1.Sex,s1.Score);

Console.Read();
}追问

谢谢

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答