I have this method:
public static T To<T>(this char o) where T : struct { return (T)Convert.ChangeType(o, typeof(T)); } If I InvalidCastException double (or float) in place of T, then an InvalidCastException is issued with a text like System.InvalidCastException: Недопустимое приведение "Char" к "Double". So what's wrong with double? The type is clearly greater than char. Now this method looks like this:
public static T To<T>(this char o) where T : struct { var obj = Convert.ChangeType(o, typeof(int)); return (T)Convert.ChangeType(obj, typeof(T)); } The question itself is in the title. Is this somehow explained somewhere in terms of logic? I did not find the answer.