ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 인덱서
    프로그래밍 언어/클래스 2011. 8. 2. 13:55

    using System;

    class Color
    {
        private string[] color = new string[5];

        public string this[int index] {
            get { return color[index]; }
            set { color[index] = value; }
        }
    }

    class IndexerApp
    {
        public static void Main() {
            Color c = new Color();
            c[0] = "WHITE";
            c[1] = "RED";
            ..
            for (int i = 0; i < n; i++) Console.WriteLine("Color is " + c[i]);


        }
    }


Designed by Tistory.