title: How to declare a variable for global use
body: <p>I've searched forum for similar issues and as I understand, global variables is to be avoided. For me that is not logical yet, as I'm new to programming. If I've understood all this correctly, a static variable should do the job that I'm looking for.</p>
  
  <p>I've made a combobox of four choices in the mainwindow and when a comboboxitem is selected, variable b is declared. This is done in a <code>private void SelectionChanged.</code></p>
  
  <p>When the comboboxitem declaring variable b is selected, a usercontrol pops up. I want to use variable b further in my program, but I can't access it. I've tried to declare <code>static int b;</code> in the beginning of the code, but I'm not sure if I understand the use of a static variable correctly. Can someone please help me?</p>