title: Parse Value to Int, String, UInt, etc. Based on Selected Item in ComboBox
body: <p>I'm just posting mostly to see if there is a better way to do this. My biggest pet peeve in C# is definitely the excessive overuse of If statements to determine what function should be executed ie:</p>
  
  <pre><code>if (comboBoxEdit1.Text == "Soup")
  
  else if (comboBoxEdit1.Text == "Salad")
  //Continues on for 10 more statements
  </code></pre>
  
  <p>So what I am wondering is if it is possible for me to determine how I should parse a certain value inside of a textbox, based on what is selected index of my combobox is. 
  ie: comboBox is Int32 </p>
  
  <pre><code>Int32.TryParse(textEdit1.Text, out i); 
  </code></pre>
  
  <p>Is the best way really to use the if statements? Any help would be appreciated!</p>
  
  <p>Edit: Full Code</p>
  
  <pre><code>//Convert.To(x) depends on combo box
      searchVal = BitConverter.GetBytes(Convert.ToUInt32(searchBox.Text));
                  toGet = (uint)searchVal.Length;
  
  for (uint i = 0; i &lt;= memSize/toGet; i++)
              {
                  uint address = startAddress + (i * toGet);
                  byte[] recoveredMem = XboxSupport.GetMem(address, toGet);
  if (recoveredMem == searchVal)
                      {
                          if (valType == "UInt32")
                          {
                              uint val = BitConverter.ToUInt32(recoveredMem, 0);
                              siInfo.Caption = String.Format("{0} Found At Address: {1}", val, String.Format("0x" + String.Format("{0:X}", address)));
                              File.AppendAllText(path, String.Format("0x" + String.Format("{0:X}", address) + " | {0}", "{1}", val, Environment.NewLine));
                          }
      }
  </code></pre>
  
  <p>Basic Summary of Code: 
  Recovers memory from a specific block, determined by the user, and searches that area for a value they would like to find during run time, then compiles a list of the search results inside a text file.</p>