D
deko
I have a method I need to pass an object reference to like this:
private void updateSchedule(object obj)
{
if (obj is ThisObj)
{
myVar1 = obj.PropertyA
myVar2 = objPropertytB
}
else if (obj is ThatObj)
{
myVar3 = obj.Property1
myVar4 = obj.Property2
}
else if (obj is OtherObj)
{
myVar5 = obj.PropertyI
myVar6 = objPropertyII
}
}
The properties of the different objects are not related in any way.
What is the best way to test for object type? GetType? typeof? examples?
Thanks in advance.
private void updateSchedule(object obj)
{
if (obj is ThisObj)
{
myVar1 = obj.PropertyA
myVar2 = objPropertytB
}
else if (obj is ThatObj)
{
myVar3 = obj.Property1
myVar4 = obj.Property2
}
else if (obj is OtherObj)
{
myVar5 = obj.PropertyI
myVar6 = objPropertyII
}
}
The properties of the different objects are not related in any way.
What is the best way to test for object type? GetType? typeof? examples?
Thanks in advance.