c# - Why can't we define a constant variable as static? -
this question has answer here:
- using consts in static classes 4 answers
public static const string var1 = "abc";//compile time error public static readonly string var2 = "def"; why can't define constant static ?
constants static redundant , resolved @ compile time.
for example:
const x = 5; int = x + x; basically compiles to:
int = 5 + 5; see here more information - http://msdn.microsoft.com/en-us/library/ms173119(v=vs.80).aspx
Comments
Post a Comment