title: Arranging values of array in Ascending order
body: <p>I couldn't get it to work, I am trying to arrange the values of the array in ascending order by using for loop.     </p>
  
  <pre><code>        int[] arr = new int[5] { 5, 6, 2, 4, 1 };
  
          for (int i = 0; i &lt;= arr.Length; i++)
          {
              if (arr[i] &gt; arr[i + 1])
              {
                  int temp = arr[i + 1];
                  arr[i] = arr[i + 1];
                  arr[i] = temp;
              }
  
              Console.Write(arr[i]);
          }
  </code></pre>