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

📄 this1.cs

📁 深入浅出C#,学习C#比较好的用例,能够很快掌握C#.
💻 CS
字号:
using System;

class Indexclass
{
	private int []array=new int[10];
	public int this[int index]
	{
		get
		{
			if(index<0||index>=10)
				return 0;
			else
				return array[index];
		}
		set
		{
			if(!(index>=10||index<0))
				array[index]=value;
		}
	}
}

class Mainclass
{
	public static void Main()
	{
		Indexclass myclass=new Indexclass();
		Console.Write("输入要赋值元素的下标:");
		string s=Console.ReadLine();
		int index=int.Parse(s);

		Console.Write("请输入值:");
		string str=Console.ReadLine();
		int n=int.Parse(str);

		myclass[index]=n;
		Console.WriteLine("current value:myclass[{0}]={1}",index,myclass[index]);
	}
}

⌨️ 快捷键说明

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