using System;
public class MyValue {
public String Name;
}
class CardDeck {
private MyValue[] Cards = new MyValue[52];
public MyValue this[int index] {
get {
return Cards[index];
}
set {
Cards[index] = value;
}
}
public static void Main(String[] args) {
try {
CardDeck PokerDeck = new CardDeck();
MyValue HiddenAce = PokerDeck[53];
} catch (IndexOutOfRangeException e) {
Console.WriteLine(e.Message);
} finally {
// Cleanup code
}
}
}
|