c# - Why can't we define a constant variable as static? -


this question has answer here:

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

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -