J
Jon Shemitz
How come
const string S = "string"; // valid
is valid but
const Type T = typeof(string); // invalid
is not? "C# Language Specification" chapter 7.15 defines a constant
expression as being of the string / char / numeric types that are
aliased to System.X types, but 7.15 certainly doesn't *explain* the
type restriction.
Why is System.String a valid type for a constant expression, but
System.Type is not? Putting either on the stack involves runtime calls
.....
const string S = "string"; // valid
is valid but
const Type T = typeof(string); // invalid
is not? "C# Language Specification" chapter 7.15 defines a constant
expression as being of the string / char / numeric types that are
aliased to System.X types, but 7.15 certainly doesn't *explain* the
type restriction.
Why is System.String a valid type for a constant expression, but
System.Type is not? Putting either on the stack involves runtime calls
.....