title: Declaring variables in another class - pros and cons
body: <p>I'm a beginner in C# and am trying to understand the effects of declaring variables in different scopes. Is there any appreciable performance difference between:</p>
  
  <p><strong>Example 1</strong></p>
  
  <pre><code>class A
  {
     static int i;
     static string temp;
  }
  
  class B
  {
     while(true)
     {
         A.i=10;
         A.temp="Hello";
     }
  }
  </code></pre>
  
  <p><strong>Example 2</strong></p>
  
  <pre><code>class B
  {
     int i;
     string temp;
     while(true)
     {
         i=10;
         temp="Hello";
     }
  }
  </code></pre>
  
  <p><strong>Example 3</strong></p>
  
  <pre><code>class A
  {
     public int i;
     public string temp;
  }
  
  class B
  {
  A D = new A();
     while(true)
     {
         D.i=10;
         D.temp="Hello";
     }
  }
  </code></pre>