title: Get member variable via other variable name C#
body: <p>I wasn't sure how else to title this question.<br>I am trying to retrieve member variables of a class via another variable. Let me explain with an example. </p>
  
  <p>This is my code where I am trying to access the value of a member variable in the <code>Network</code> class.<br>
  (<code>item</code> is <strong>NOT</strong> the name of the variable I am trying to access. <code>item</code> holds the string of the variable I am trying to access)</p>
  
  <pre><code>private void addKeyValuePairRow(string item) {
      addRow(item);
      addKeyLabel(item, false);
      addValueLabel(item);
  
      if (item.Contains("_"))
          item = item.Replace("_", "");
  
      setValue(Network[item]);
  }
  </code></pre>
  
  <p><strong>Network</strong> class:</p>
  
  <pre><code>public class Network {
      public string DefaultGateway { get; set; }
      public string ExternalIP { get; set; }
      public string SSID { get; set; }
      public string NetworkConnection { get; set; }
      public string NetworkConnectionType { get; set; }
      public string InternetConnection { get; set; }
  
      ...
  }
  </code></pre>
  
  <p>So say I am trying to get <code>DefaultGateway</code>, this would be my code calling the method:</p>
  
  <pre><code>addKeyValuePairRow("Default_Gateway");
  </code></pre>
  
  <p>I feel like this would be a relatively simple task but cannot find anything on it.</p>
  
  <p>Any help appreciated.</p>