
C# 定义结构类型(有学号,姓名,性别和程序设计成绩四个字段),声明该结构类型变量,用赋值语句对此
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();
}
{
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();
}
追问
谢谢
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询