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”的具有相同参数类型的成员
{
get
{
if (this.m_hashConfigs == null)
{
return null;
}
return (ConfigGraph) this.m_hashConfigs.get_Item(iGraphID);
}
}错误 CS0111: 类型“Lighthouse.LmsExpress.Graphs.GraphCollection”已定义了一个名为“this”的具有相同参数类型的成员
解决方案 »
- DataGridView可不可以这样
- 还是关于周期提醒的问题?
- dataGrid中有若干行数据,有一个MouseUp事件可以得到点的行数,如果换了分辨率,即使双击标题栏使窗口最大化也可以触发MouseUp事件,请问怎么
- windows服务调用托盘应用程序无法显示托盘
- 超难问题:datagridview的DataSource 属性被赋值后,datagridview依次发生哪些事件?
- CheckedListBox如何单选
- 多线程应用场合?
- 为什么我的com组件手工注册跟编译时的注册不一样
- 有关Read 方法?
- 这个咋弄啊
- C# button 双击事件求解答!!!
- C#右移运算问题。有些不明白。请教。
请问你这是什么东东? this是关键词,不要试图用它来作成员变量!
{
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;
}
}
}
public new ConfigGraph this[int iGraphID]
或
public override ConfigGraph this[int iGraphID]
to 1L: this是indexer
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; }
}
}
}