Saturday, October 3, 2009

Find object is of which class

public class Super
{

}

public class a : Super
{

}


public class b : Super
{

}

public class c : Super
{

}



Super objSuper;
a objA = new a();
b objB = new b();
c objC = new c();

objSuper = objB;

if (objSuper is a)
{
Response.Write("Of A");
}
else if (objSuper is b)
{
Response.Write("Of B");
}
else
{
Response.Write("Of C");
}


================OutPut===================
Of B

No comments: