P
Pekka Henttonen
Let's say there is an object which has several methods all taking
different object as argument:
class TestObject {
public void SetTitle( TitleObject title );
public void SetDate( DateObject date );
<etc.>
}
How can you find out which method to call at runtime when you have an
object which should be passed to a method? I suppose there is a cleaner
way to do it than by testing all possibilities by a set of if-clauses:
public void SetNull( Object o ) {
if ( o is TitleObject ) {
SetTitle(null);
} else
if ( o is DateObject ) {
SetDate(null);
} else
<etc.>
}
With best regards
Pekka
Kerava, Finland
different object as argument:
class TestObject {
public void SetTitle( TitleObject title );
public void SetDate( DateObject date );
<etc.>
}
How can you find out which method to call at runtime when you have an
object which should be passed to a method? I suppose there is a cleaner
way to do it than by testing all possibilities by a set of if-clauses:
public void SetNull( Object o ) {
if ( o is TitleObject ) {
SetTitle(null);
} else
if ( o is DateObject ) {
SetDate(null);
} else
<etc.>
}
With best regards
Pekka
Kerava, Finland