Why are member constants available even if there are no instances of a its class?
Posted
by flockofcode
on Stack Overflow
See other posts from Stack Overflow
or by flockofcode
Published on 2010-06-14T20:09:57Z
Indexed on
2010/06/14
20:12 UTC
Read the original article
Hit count: 187
c#
1) Why are member constants available even if there are no instances of a its class?
2) Is the only reason why constant expressions need to be fully evaluated at compile time due to compiler replacing constant variable with literal value?
3) Since string is also an object, I would think the following would produce an error, but it doesn’t. Why?
class A
{
const string b = “it works”;
}
thank you
© Stack Overflow or respective owner