fork download
  1. using System;
  2.  
  3. class MyClass
  4. {
  5. private int[] array = new int[5];
  6.  
  7. public int this[int index]
  8. {
  9. get
  10. {
  11. return array[index];
  12. }
  13. set
  14. {
  15. array[index] = value;
  16. }
  17. }
  18. }
  19.  
  20. class Program
  21. {
  22. static void Main()
  23. {
  24. // Допустима ли чисто теоретически такая инициализация?
  25. MyClass my = new MyClass()
  26. {
  27. [0] = 1,
  28. [1] = 2,
  29. [2] = 3,
  30. [3] = 4,
  31. [4] = 5
  32. };
  33.  
  34. Console.ReadKey();
  35. }
  36. }
Success #stdin #stdout 0s 131776KB
stdin
Standard input is empty
stdout
Standard output is empty