I got an Int16 value, from the database, and need to convert this to an enum type. This is unfortunately done in a layer of the code that knows very little about the objects except for what it can gather through reflection.
As such, it ends up calling Convert.ChangeType which fails with an invalid cast exception.
I found what I conside...
I'm fairly new to C# and .NET - I'm trying to get conversion to work from an integer to an enum. The conversion must be performable by ChangeType (outside of my demo below this is fixed as it's within the data binding framework) and from what I've read it should work with what I'm doing, but I get an exception and if I place breakpoints...
How can I convert a Decimal datatype to Object and still observe the IConvertable interface ToType() method. This is preliminary work in order to convert a custom datatype (based on Decimal) using Convert.ChangeType.
EDIT: we would like to convert to object so that we can support the ToType method of IConvertible. this method returns ty...
The Convert class has been in existence since .NET 1.0. The IConvertible interface has also existed since this time.
The Convert.ChangeType method only works on objects of types that implement IConvertible (in fact, unless I'm mistaken, all of the conversion methods provided by the Convert class are this way). So why is the parameter ty...