using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ConsoleApplication3
{
public class BaseClass
{
/// <summary>
/// 常量
/// </summary>
public const int Number = ; /// <summary>
/// 属性
/// </summary>
public int ID { get; set; } /// <summary>
/// 字段
/// </summary>
public string Name; /// <summary>
/// 方法
/// </summary>
/// <returns></returns>
public void SayHello()
{
Console.WriteLine("我是无返回类型的方法");
} /// <summary>
/// 索引
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public int this[int index]
{
get
{
switch (index)
{
case :
return ;
break;
case : return ;
break;
case : return ;
break;
case : return ;
break;
default: return ;
break;
}
}
set
{ switch (index)
{
case :
ID = value;
break;
case : ID = value;
break;
case : ID = value;
break;
case : ID = value;
break;
default: ID = value;
break;
}
} }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ConsoleApplication3
{
public class MyClass : BaseClass
{
/// <summary>
/// 常量
/// </summary>
new public const int Number = 10; /// <summary>
/// 属性
/// </summary>
new public int ID { get; set; } /// <summary>
/// 字段
/// </summary>
public string Name; /// <summary>
/// 方法
/// </summary>
/// <returns></returns>
public string SayHello()
{
string str = "hello";
return str;
} /// <summary>
/// 索引
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public int this[int index]
{
get
{
switch (index)
{
case :
return ;
break;
case : return ;
break;
case : return ;
break;
case : return ;
break;
default: return ;
break;
}
}
set
{ switch (index)
{
case :
ID = value;
break;
case : ID = value;
break;
case : ID = value;
break;
case : ID = value;
break;
default: ID = value;
break;
}
} }
}
}
使用new关键字隐藏基类成员