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

📄 example 2.cs

📁 北大青鸟-Cs学生用书-教师用书实例源代码.rar
💻 CS
字号:
using System;
class VCDIndexer
{
	private int [] vcdCollection = new int[10];
	public int this[int index]
	{
		get
		{
			if (index < 0 || index >=10)
				return 0;
			else
				return vcdCollection[index];
		}
		set
		{
			if (!(index < 0 || index >= 10))
				vcdCollection[index] = value;
		}
	}
}
namespace Example_2
{
	/// <summary>
	/// 此程序演示索引器的用法
	/// </summary>
	class Class1
	{
		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			//
			VCDIndexer objVCD = new VCDIndexer();
			objVCD[1]=125;
			objVCD[2]=250;
			objVCD[3]=400;
			for(int intA = 0;intA <= 3;intA++)
			{
				Console.WriteLine("VCD Collection #{0} = {1}", intA, objVCD[intA]);
			}
			//
		}
	}
}

⌨️ 快捷键说明

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