Why does System.Guid not implement System.IConvertible?

c#, clr, guid

Solution

IConvertible requires the type be able to convert it's data to most of the primitives. How would you represent a Guid as a float for example?

Because Guid cannot implement most of the interface methods it's expected to not declare itself otherwise.

Now on the real question: What are you trying to accomplish?

Problem

I recently tried to return an object of type Guid from a method accepting `<T>`, however the compiler gave me the following error: The type 'System.Guid' cannot be used as type parameter 'T' in the generic type or method 'MyGenericMethod'. There is no boxing conversion from 'System.Guid' to 'System.IConvertible'. After investigation I realised that the compiler message was caused due to the Guid type not implementing the System.IConvertible interface. MSDN states the following: This interface provides methods to convert the value of an instance of an implementing type to a common language runtime type that has an equivalent value. The provided list of types does not include Guid; Can anyone explain/provide a use case as to why this is the case?

Original source