⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 static1.cs

📁 深入浅出C#,学习C#比较好的用例,能够很快掌握C#.
💻 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 + -