Query
How can i declare a global variable in c#?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Nanhe SiddiqueRank #1,103 · 1.7K reputationPosted May 7, 2015, 11:27 PM EDT
If you want a variable to be visible application wide you can use a static variable.
For example:
Then anywhere in your application you want to access SomeVariable you just do:
globalVariable.v
If a value is in a namespace then it wouldn't be visible to others. You have to use:
namespaceName.ClassName.VariableName
or
using namespaceName;
ClassName.VariableName
Deena eliz49 reputationPosted May 7, 2015, 11:27 PM EDT
http://www.dotnetperls.com/global-variable
http://stackoverflow.com/questions/14368129/c-sharp-global-variables
refer these links.. its may help u..
thank you..