readonly2.cs

来自「深入浅出C#,学习C#比较好的用例,能够很快掌握C#.」· CS 代码 · 共 37 行

CS
37
字号
using System;
class Customer
{
	public readonly string name;
	public readonly int age;
	public static int numofcustomer=0;
	public Customer(string pname,int page)
	{
		name=pname;
		age=page;
		numofcustomer++;
	}

	public static void Main()
	{
		int choose=1;
		while(choose==1)
		{
			Console.WriteLine("please input the customer's name and age:");
			Console.Write("name:");
			string str=Console.ReadLine();

			Console.Write("age:");
			string s=Console.ReadLine();
			int a=int.Parse(s);

			Customer customer=new Customer(str,a);

			Console.WriteLine("Now there have been {0} customers.",numofcustomer);
			Console.WriteLine("Is there another one?1=yes,2=no");

			string ch=Console.ReadLine();
			choose=int.Parse(ch);
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?