this关键字
- 引用类的当前实例,包括继承而来的方法,通常可以省略。
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
public Person(string Name, int Age)
{
this.Age = Age;
this.Name = Name;
}
}
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
public Person(string Name, int Age)
{
this.Age = Age;
this.Name = Name;
}
public void CallTest(Person person)
{
Console.WriteLine(person.Name + person.Age);
}
public void Call()
{
CallTest(this);
}
}
public class Person
{
string[] PersonList = new string[10];
public string this[int param]
{
get { return PersonList[param]; }
set { PersonList[param] = value; }
}
}