class Base1:IDisposable
{
public void Dispose()
{
Console.WriteLine("Base Dispose");
}
public virtual void Display()
{
Console.WriteLine("Base Display");
}
}
class Child1 :Base1,IDisposable
{
public new void Dispose()
{
Console.WriteLine("Child Dispose");
}
public override void Display()
{
Console.WriteLine("Child Display");
}
}
public class MainClass1
{
public void Show()
{
Base1 objBase = new Child1();
objBase.Display();//Child Display
objBase.Dispose();//Base Dispose
((IDisposable)objBase).Dispose();// Child Dispose
IDisposable objDisp = objBase;
objDisp.Dispose();//Child Dispose
}
}
{
public void Dispose()
{
Console.WriteLine("Base Dispose");
}
public virtual void Display()
{
Console.WriteLine("Base Display");
}
}
class Child1 :Base1,IDisposable
{
public new void Dispose()
{
Console.WriteLine("Child Dispose");
}
public override void Display()
{
Console.WriteLine("Child Display");
}
}
public class MainClass1
{
public void Show()
{
Base1 objBase = new Child1();
objBase.Display();//Child Display
objBase.Dispose();//Base Dispose
((IDisposable)objBase).Dispose();// Child Dispose
IDisposable objDisp = objBase;
objDisp.Dispose();//Child Dispose
}
}
No comments:
Post a Comment