The C # specification first says:
If the default type of an expression is evaluated at runtime prior to the reference type, the null result is converted to that type. If the type in the default expression is evaluated at runtime to the type of value, the result is the value of the default value (ยง4.1.2).
So, it seems that the default expression is evaluated at runtime ... but after it says:
The default value is a constant expression (ยง7.19) if type is a reference type or a type parameter, which is known to be a reference type (ยง10.1.5). In addition, the default expression is a constant expression if the type is one of the following value types: sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, decimal, bool, or any type of enumeration.
since there can be a defaultconstant expression, therefore compilation time is estimated if only the type of runtime is checked?
For example, if I write something like:
J k = default(J);
where Jis the type parameter, only at runtime, when we provide the type of the argument, we can know whether the Jreference type or value type. So what happens during compilation?