static void Main() { int i = 16; Indexators a = new Indexators(); //работаем как с массивом Console.WriteLine("2 в степени {0} равно {1}", i, a[16]); //свойсто Properties temp = new Properties(); temp.MyProp = 100; temp.Show(); temp.MyProp = 50; temp.Show(); temp.MyProp *= 2; temp.Show(); //а так не присвоится из-за ограничения в свойстве temp.MyProp = -50; temp.Show(); }
static void Main() { Indexators a = new Indexators(10); //выйдем за границы массива при присваивании for (int i = 0; i < a.Length + 5; i++) { if (a.ErrorAray) { Console.WriteLine("Превышение границ."); } a[i] = i; } //выйдем за границы массива при считывании for (int i = 0; i < a.Length + 5; i++) { Console.Write("{0}, ", a[i]); if (a.ErrorAray) { Console.WriteLine("Превышение границ."); } } }