How to declare a global variable in c# window application which is accesseble in all windows form?
please help me.
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 attend4days leftRegister
Kirtan PatelRank #292 · 8.6K reputationPosted Jan 16, 2010, 5:28 AM EST
like if you want to declare global variable in form1 that will be accessible to all form then
in form1
declare variable oud side of all methods in form1 like
public static int global_var;
now you can access it at an other form like
int test = Form1.global_var ;
without creating even instance of Form1.
if my answer helps you then check "Do you like this answer" check box :)
Vikas AhlawatRank #2,648 · 525 reputationPosted Jan 16, 2010, 5:43 AM EST
Kirtan PatelRank #292 · 8.6K reputationPosted Jan 16, 2010, 9:28 PM EST