title: c# executed even when in false loop
body: <p>I am trying to use a basic if else case, but the if is executed no matter what.</p>
  
  <p>This is the code found in the backend, on the aspx.cs file.</p>
  
  <pre><code>if (1==2)
              {
                  // 22/09/2014 12:00:00 AM for en
                  //format date for submit
                  Dateformatted = this.DateField.Value.ToString();
                  DateSplit = Dateformatted.Split('/');
                  yearAt0 = DateSplit[2].Split(' ');
                  Datetosubmit = yearAt0[0] + "/" + DateSplit[1] + "/" + DateSplit[0] + " 00:00:00";
              }
              else
              {
                  // 2014-09-22 00:00:00 for fra
                  //format date for submit
                  Dateformatted = this.DateField.Value.ToString();
                  DateSplit = Dateformatted.Split('-');
                  dayAt0 = DateSplit[2].Split(' ');
                  Datetosubmit = DateSplit[0] + "/" + DateSplit[1] + "/" + dayAt0[0] + " 00:00:00";
              }
  </code></pre>
  
  <p>This is the error I get (line 1209 is red):</p>
  
  <pre><code>   System.IndexOutOfRangeException: Index was outside the bounds of the array.
     Line 1207:                string Dateformatted = this.DateFieldEdit.Value.ToString();
     Line 1208:                string[] DateSplit = Dateformatted.Split('/');
  Line 1209:                string[] yearAt0 = DateSplit[2].Split(' ');
     Line 1210:                string Datetosubmit = yearAt0[0] + "/" + DateSplit[1] + "/" +     DateSplit[0] + " 00:00:00";
     Line 1211:
  </code></pre>
  
  <p>This clearly indicates that the code inside the false part of the if statement was executed. Is there a reason for this? How can I fix this? </p>
  
  <p>Note: The if (1==2) was added to simplify the example, it is normally a parameter </p>