title: Avoidable if-else
body: <p>Here is a finished Roman to Decimal numeral convertor.</p>
  
  <pre><code>Dictionary&lt;char,int&gt; nTrans = new Dictionary&lt;char,int&gt;();
              nTrans.Add('I',1);
              nTrans.Add('V', 5);
              nTrans.Add('X', 10);
              nTrans.Add('L', 50);
              nTrans.Add('C', 100);
              nTrans.Add('D', 500);
              nTrans.Add('M', 1000);
  
              string rNum = "XV";
              int dNum = 0;
  
              for (int i = 0; i &lt; rNum.Length; i++)
              {
                  if (i &lt; rNum.Length-1)
                  {
                      if (nTrans[rNum[i]] &lt; nTrans[rNum[i + 1]])
                      {
                          dNum -= nTrans[rNum[i]];
                      }
                      else
                      {
                          dNum += nTrans[rNum[i]];
                      }
                  }
                  else
                  {
                      dNum += nTrans[rNum[i]];
                  }
              }
  </code></pre>
  
  <p>But I can't figure out how to escape from using this if-else statement:</p>
  
  <pre><code>if (i &lt; rNum.Length-1)
  {
  //Code
  }
  else
  {
  dNum += nTrans[rNum[i]];
  }
  </code></pre>
  
  <p>Any suggestions how I can avoid using it? The question is only for optimizing and improving my coding skills!</p>