I want to determine whether MyBindingSource.DataSource
is assigned to the designer-set Type, or if it has been assigned an object instance. This is my current (somewhat ugly) solution:
object result = MyBindingSource.DataSource;
if(result.GetType().ToString() == "System.RuntimeType")
return null;
return (ExpectedObjType) result;
The System.RuntimeType
is private and non-accessible, so I can't do this:
if (object.ReferenceEquals(result.GetType(), typeof(System.RuntimeType)))
return null;
return (ExpectedObjType) result;
I was just wondering if a better solution exists -- one that doesn't rely on converting the Type to a string?