Given these C# classes (generated by WCF, I can't change these):
public SysState GetSysState();
public class SysState { /* nothing much here */}
public class Normal : SysState { /* properties & methods */ }
public class Foobar : SysState { /* different properties & methods */ }
My code (currently):
SysState result = GetSysState();
if (result is Normal) HandleNormal((Normal) result);
if (result is Foobar) HandleFoobar((Foobar) result);
My question: I keep feeling I'm missing something obvious, that I shouldn't need to check type explicitly. Am I having a senior moment?