I have classes A,B,C,D,E,F that implement InterfaceBase.
Whats the best way to down cast obj to the correct type?
Is there a more elegant way to do this than?
Public Void DoSomething(Int erfaceBase obj)
{
if(obj is A)
((A)obj).Method ThatOnlyACanDo( );
else if(obj is B)
((B)obj).Method ThatOnlyBCanDo( );
....
}
if and else if can become confusing when more options (more parameters,
child types) are added.
Tem
Whats the best way to down cast obj to the correct type?
Is there a more elegant way to do this than?
Public Void DoSomething(Int erfaceBase obj)
{
if(obj is A)
((A)obj).Method ThatOnlyACanDo( );
else if(obj is B)
((B)obj).Method ThatOnlyBCanDo( );
....
}
if and else if can become confusing when more options (more parameters,
child types) are added.
Tem
Comment