How would I go about the following… I have a control that can be bound to different data types… String, Int, Int32, DateTime, etc… but generically the result is stored into a generic “object” data type. So, I use another field to identify the EXPECTED type such as..
String BoundDataType = "System.String" // or System.Int32 or date/time, etc.
object ChosenValue;
For comparison purposes, I would now have to enforce typecasting of expected format, such as
(DataBoundType)ChosenValue == (DataBoundType)TestAgainstThisValue;
I know i could put inside a switch, or overloaded functions with different Signatures per data type, but looking for a more generic way to handle directly.
Thanks
You don’t actually need a separate
BoundDataTypeproperty –object.GetType()will suffice.As for comparison, most standard types implement IComparable interface, which can be used to test for equality.