CSharp examples for Custom Type:Indexer
Access array field with indexer
using System;/*from ww w .ja v a 2 s .c o m*/ class BirthsList { private uint[] births = new uint[4]; public uint this [uint index] { get { return births[index]; } set { births[index] = value; } } } class BirthListTester { public static void Main() { BirthsList bLDenmark = new BirthsList(); uint sum; bLDenmark[0] = 1; bLDenmark[1] = 2; bLDenmark[2] = 4; bLDenmark[3] = 6; sum = bLDenmark[0] + bLDenmark[1] + bLDenmark[2] + bLDenmark[3]; Console.WriteLine("Sum the four regions: {0}", sum); } }