📄 static1.cs
字号:
using System;
public class Student
{
public int id;
public string name;
public int age;
public Student()
{
id=0;
name="noname";
age=0;
number=0;
}
public Student(string pname, int id1,int age1)
{
name = pname;
id = id1;
age=age1;
}
public static int number;
public static void Addstudent()
{
++number;
}
}
class MainClass:Student
{
public static void join()
{
while(i==1)
{
Console.Write("Enter the student's name: ");
string name = Console.ReadLine();
Console.Write("Enter the student's ID: ");
string n = Console.ReadLine();
int id=int.Parse(n);
Console.WriteLine("Enter the student's age");
string str=Console.ReadLine();
int age=int.Parse(str);
Student student = new Student(name,id,age);
Addstudent();
Console.WriteLine("the information of the new student:");
Console.WriteLine("id:{0},name:{1},age:{2}",student.id,student.name,student.age);
Console.WriteLine("now we have {0} students",number);
Console.WriteLine("add another one?1=yes,2=no:");
string s=Console.ReadLine();
i=int.Parse(s);
}
}
public static void Main()
{
Console.WriteLine("now our class has {0} students,add anyone else?1=yes,2=no",number);
string s=Console.ReadLine();
i=int.Parse(s);
switch(i)
{
case 1:join();break;
case 2:return;
}
}
public static int i;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -