也可以知道,就是方法挺傻: 比如:你可以定义一个int a变量,设置#region属性public int A{set{this.a=value}}#endregion 然后当a调时=1,b调时=2,即可!
同意 SOAD_OOAD_SOAP() 的说法
protected void me() { Type t = this.GetType(); if( t== Typeof(A) ) { } else if( t== TypeOf(B) ) {} else if( t = typeof(C) ) {}
}
自己试了下,可行 namespace ConsoleApplication1 { class Program { static void Main(string[] args) { B b = new B(); b.init(); } } } class A { public void init() { if (this.GetType()==typeof(B)) { Console.Write("B"); } if (this.GetType() == typeof(C)) { Console.Write("C"); } } }
比如:你可以定义一个int a变量,设置#region属性public int A{set{this.a=value}}#endregion 然后当a调时=1,b调时=2,即可!
{
Type t = this.GetType();
if( t== Typeof(A) )
{ }
else if( t== TypeOf(B) )
{}
else if( t = typeof(C) )
{}
}
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
B b = new B(); b.init(); }
}
}
class A
{
public void init()
{
if (this.GetType()==typeof(B))
{
Console.Write("B");
}
if (this.GetType() == typeof(C))
{
Console.Write("C");
}
} }