are conversion operators only applicable to numeric types .net

I was wondering whether overriding conversion operators is only applicable to numeric types? If not in what instances would the implicit or explicit conversion operator be applicable to other value types or reference types. An example would be great. Thanks


No - you can use any type.

For example, XAttribute has a range of conversions defined that make various conversions simple:

    XAttribute attrib = new XAttribute("Foo", "12345");
    int i = (int)attrib;
    string s = (string)attrib;

Another useful example is Jon's NonNullable<T> - this is intended to work neatly with classes while disallowing nulls. The conversion operators make it easy to use.

Need Your Help

Sending PUT/DELETE data with a XMLHttpRequest

javascript xml httprequest http-delete http-put

I used the example from Send POST data using XMLHttpRequest to create this JavaScript code:

Pygame: Making a sprite move along a predetermined path at a constant speed

python pygame

I'm working on a tower defense game in Pygame in which the enemies advance towards the base along a path that I have set for them; if you've played flash games like VR Defender Y3K and Canyon Defen...