When I want to cast an object to System.Drawing.Color (using as), I got the following error at compile time :
The as operator must be used with a reference type or nullable type ('System.Drawing.Color' is a non-nullable value type)
What can I do ?
My code is like :
MyClass.indoorColor = parsedObject as System.Drawing.Color;
The System.Drawing.Color is a Struct and can’t be casted with the ‘as’ keyword from a reference type to a value type.
Try to use one of the ‘From..’ Methods from System.Drawing.Color by passing parameters:
http://msdn.microsoft.com/en-us/library/system.drawing.color_methods.aspx