public ConfigGraph this[int iGraphID]
        {
            get
            {
                if (this.m_hashConfigs == null)
                {
                    return null;
                }
                return (ConfigGraph) this.m_hashConfigs.get_Item(iGraphID);
            }
        }错误 CS0111: 类型“Lighthouse.LmsExpress.Graphs.GraphCollection”已定义了一个名为“this”的具有相同参数类型的成员

解决方案 »

  1.   

    public ConfigGraph this[int iGraphID]你这里有个 this,太奇怪了哦!
    请问你这是什么东东? this是关键词,不要试图用它来作成员变量!
      

  2.   

       class Class1
        {
            static void Main(string[] args)
            {
                Model m = new Model();
                m[3] = "a";
                Console.WriteLine(m[3]);
            }
        }
        public class Model
        {
            private string[] str;
            public Model()
            {
                str = new string[5];
            }
            public string this[int index]
            {
                get
                {
                    if (index >= 0 && index < str.Length)
                        return str[index];
                    else
                        return "";
                }
                set
                {
                    if (index >= 0 && index < str.Length)
                        str[index] = value;
                }
            }
        }
      

  3.   

    两个类之间存在继承吗,那么要么用new去覆盖或者用override去重载
    public new ConfigGraph this[int iGraphID]

    public override ConfigGraph this[int iGraphID]
      

  4.   

    正确。
    to 1L: this是indexer
      

  5.   

    热乎乎的索引器demo
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                School mc = new School("高三一班");
                mc.Students["b"].say();
                mc.Students[1].say();            Console.ReadKey();
            }
        }    class Student
        {
            Student[] stus = new Student[3];
            public Student(string _name, int _age)
            {
                this.Name = _name;
                this.Age = _age;
            }
            public Student()
            {
                stus[0] = new Student("a", 21);
                stus[1] = new Student("b", 33);
                stus[2] = new Student("c", 44);
            }
            public void say()
            {
                Console.WriteLine("大家好,我叫{0},今年{1}岁!", name, age);
            }        private string name;
            public string Name
            {
                get { return name; }
                set { name = value; }
            }        private int age;
            public int Age
            {
                get { return age; }
                set { age = value; }
            }
            public Student this[int index]
            {
                get { return stus[index]; }
            }        public Student this[string name]
            {
                get
                {
                    int j = -1;
                    bool equalse = false;
                    for (int i = 0; i < stus.Length; i++)
                    {
                        if (stus[i].name == name)
                        {
                            j = i;
                            equalse = true;
                            break;
                        }
                    }
                    if (equalse)
                    {
                        return stus[j];
                    }
                    else
                    {
                        return null;
                    }
                }
            }
        }    class School
        {
            //构造函数
            public School(string name)
            {
                this.Name = name;
                this.Students = new Student();
            }        //班级名字
            private string name;
            public string Name
            {
                get { return name; }
                set { name = value; }
            }        //班级学生
            private Student students;
            public Student Students
            {
                get { return students; }
                set { students = value; }
            }
        }
    }