title: Function always returns null?
body: <p>This function always returns null. sString is a class with a string "Name" and string "Value" values. Don't ask why I'm not using a regular string-- it's complicated. here's my function:</p>
  
  <pre><code>static string Get_sString(string VarName, ref List&lt;sString&gt; VarList)
  {
      foreach (sString TestsString in VarList)
      {
          if (TestsString.Name == VarName)
          {
              return TestsString.Name;
          }
      }
      return null;
  }
  </code></pre>
  
  <p>It's supposed to return the instance with the same Name value as VarName, and it works, except for the if statement <em>always is false</em>. I can't figure out why. I actually have an almost identical class called sDecimal, where the only difference is the Value property is a decimal, not a string. The Get_sDecimal() works perfectly fine with that, and the only difference between Get_sDecimal() and Get_sString() are that one tests sDecimal and one tests sString.
  <strong>Thanks!</strong></p>
  
  <p>EDIT:
  Here's sString Class.</p>
  
  <pre><code>class sString
  {
      public string Name;
      public string Value;
  
      /// &lt;summary&gt;
      /// String Value variables that may have the same name.
      /// &lt;/summary&gt;
      /// &lt;param name="n"&gt;Internal name of variable.&lt;/param&gt;
      /// &lt;param name="v"&gt;Value of variable.&lt;/param&gt;
      public sString(string n, string v)
      {
          Name = n;                    
          Value = v;                    
      }
  }
  </code></pre>
  
  <p>EDIT: Here's some output code (and output) to clear things up.</p>
  
  <pre><code>static string Get_sString(string VarName, ref List&lt;sString&gt; VarList)
          {
              foreach (sString TestsString in VarList)
              {
                  Console.WriteLine("Looking for: " + VarName);
                  Console.WriteLine("Comparing with: " + TestsString.Name);
                  if (TestsString.Name == VarName)
                  {
                      Console.WriteLine("Match!");
                      return TestsString.Name;
                  }
              }
              return null;
          }
  </code></pre>
  
  <p>Here's the output:</p>
  
  <pre>
  Looking for: Q
  Comparing with: Q
  </pre>
  
  <p>EDIT: I added a couple more variables to the list. Here's the new output:</p>
  
  <pre>
  Looking for: Q
  Comparing with: Q
  Looking for: Q
  Comparing with: Z
  Looking for: Q
  Comparing with: VariableX
  </pre>
  
  <p>Still no Match.</p>