class Program
{
static void Main(string[] args)
{
thisClass testObj = new thisClass();
Console.ReadLine();
}
}
class thisClass
{
private string A { get; set; }
public thisClass()
{
/*当前类this 访问类中属性A 静态方法无法访问A属性*/
this.A = "Test String";
Console.WriteLine(this.TestFun("TestFun :"));
}
private string TestFun(string args)
{
return args + this.A;
}
}
class Program
{
static void Main(string[] args)
{
indexClass intIndexClass = new indexClass();
intIndexClass[0] = new thisClass("intIndexClass 111");
intIndexClass[1] = new thisClass("intIndexClass 222");
indexClass stringIndexClass = new indexClass();
stringIndexClass["string1"] = new thisClass("stringIndexClass string1");
stringIndexClass["string2"] = new thisClass("stringIndexClass string2");
Console.ReadLine();
}
}
class indexClass
{
/*声明属性*/
private thisClass[] thisClassArr = new thisClass[10];
private Hashtable thisClassStrArr = new Hashtable();
/*创建索引器1 索引可以被重载,属于实例成员,不能声明为static*/
public thisClass this[int index]
{
get { return thisClassArr[index]; }
set { this.thisClassArr[index] = value; }
}
/*创建索引器2*/
public thisClass this[string index]
{
get
{
return thisClassStrArr[index] as thisClass;
}
set { this.thisClassStrArr[index] = value; }
}
}
class thisClass
{
private string A { get; set; }
public thisClass(string str)
{
/*当前类this 访问类中属性A 静态方法无法访问A属性*/
this.A = str;
Console.WriteLine(this.TestFun("TestFun :"));
}
private string TestFun(string args)
{
return args + this.A;
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有