求各位C#牛人!!
请各位大神、牛人给我一些指点,我是初学者,能不能把下面这段windows窗口程序的代码解释一下,最好吧么一句的注释解释详细一点!谢谢
using System;
namespace MyFirstProgram
{
public class Person
{
string name;
Char sex;
public Person(){}
public Person(string s,char x)
{
name=s;
sex=x;
}
public void printinfo ()
{
Console.Write(name+'('+sex+')');
}
}
public class Student:Person
{
int studentID;
int credit;
public Student(){}
public Student(int sID,int ct,string s,char x):base(s,x)
{
studentID=sID;
credit = ct;
}
void graduate()
{
if (credit>200)
Console.WriteLine("恭喜,你可以毕业了!");
}
public class Teacher:Person
{
int staffID;
int course;
public Teacher(){}
public Teacher(string s,Char x,int sID):base(s,x)
{
staffID=sID;
}
void coursenumber(int cn)
{
course=cn;
}
}
static void Main(string[] args)
{
Person a = new Person("aaa",'d');
Student Wang = new Student(12200035,120,"王贵阳",'男');
Student Chen = new Student(12010018,130,"陈小娅",'女');
Teacher Li = new Teacher("李海", '男',08100082); //,
if (Wang.credit > 100)
{
Wang.printinfo();
Console.Write("你的老师是");
Li.printinfo();
Console.WriteLine();
}
if (Chen.credit > 100)
{
Chen.printinfo();
Console.Write("你的老师是");
Li.printinfo();
Console.WriteLine();
}
}
}
}
------解决方案--------------------C# code
using System;
namespace MyFirstProgram
{
//定义Person类
public class Person
{
string name;
Char sex;
//无参数构造
public Person(){}
//带参数构造
public Person(string s,char x)
{
name=s;
sex=x;
}
public void printinfo ()
{
Console.Write(name+'('+sex+')');
}
}
//类Student继承自Person
public class Student:Person
{
int studentID;
int credit;
//无参数构造
public Student(){}
//带参数构造,base调用父类带参数构造
public Student(int sID,int ct,string s,char x):base(s,x)
{
studentID=sID;
credit = ct;
}
void graduate()
{
if (credit>200)
Console.WriteLine("恭喜,你可以毕业了!");
}
//同student类
public class Teacher:Person
{
int staffID;
int course;
public Teacher(){}
public Teacher(string s,Char x,int sID):base(s,x)
{
staffID=sID;
}
void coursenumber(int cn)
{
course=cn;
}
}
------解决方案--------------------
using System;--命名空间
namespace MyFirstProgram
{
public class Person
{
string name;--声明变量(姓名,字符串型的)
Char sex;--声明变量(性别,Char型)