title: Which is fast comparison: Convert.ToInt32(stringValue)==intValue or stringValue==intValue.ToString()
body: <p>While developing my application i came across some comparison stuff here was it:</p>
  
  <pre><code>    string str = "12345";
      int j = 12345;
      if (str == j.ToString())
      {
          //do my logic
      }
  </code></pre>
  
  <p>I was thinking that the above stuff can also be done with:</p>
  
  <pre><code>    string str = "12345";
      int j = 12345;
      if (Convert.ToInt32(str) == j)
      {
          //do my logic
      }
  </code></pre>
  
  <p>So i developed a sample code to test in terms of performance which one is better</p>
  
  <pre><code>        var iterationCount = 1000000;
          var watch = new Stopwatch();
          watch.Start();
          string str = "12345";
          int j = 12345;
          for (var i = 0; i &lt; iterationCount; i++)
          {
              if (str == j.ToString())
              {
                  //do my logic
              }
          }
          watch.Stop();
  </code></pre>
  
  <p>And second one:</p>
  
  <pre><code>  var iterationCount = 1000000;
      var watch = new Stopwatch();
      watch.Start();
      string str = "12345";
      int j = 12345;
      for (var i = 0; i &lt; iterationCount; i++)
      {
          if (Convert.ToInt32(str) == j)
          {
              //do my logic
          }
      }
      watch.Stop();
  </code></pre>
  
  <p>On running the above two tests i found the above tests were giving nearly the same time elapsed. I would like to discuss which one is the better approach? And is there any other approach better than two above two?</p>