private int a;//字段
            public int geta//属性
            {
                get
                {
                    return a;
                }
                set
                {
                    a = value;
                }
            }
 索引器与数组差不多!

解决方案 »

  1.   

    字段是被视为类的一部分的对象的实例,通常用于保存类数据
    private static string name="";
    属性特殊的类成员
    public class Student
    {
        private string name;
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
    }引器就是一类特殊的属性,可以像引用数组一样引用自己的类
    public class Student
    {public List<Student> listStudents = new List<Student>();
        public Student this[int i]
        {
            get { return listStudents[i]; }
            set { listStudents[i] = value; }
        }
    }
     Student student = new Student();
            int num = student.listStudents.Count;
            for (int i = 0; i < num; i++)
            {
                Console.WriteLine(student[i].Name); 索引访问
            }属性可以是static(静态的)而索引器则必须是实例成员
    参考