title: Traversing a 2D array as quickly as possible
body: <p>Let's say i have a fairly large 2D array (a bit over 2 million entries) containing some basic objects (in my case, it's a 2d array of pixel objects).</p>
  
  <p>My goal is to loop through every item in the 2D array and do some basic modification to the object, such as changing one of its properties or something.</p>
  
  <p>Currently i am just looping through it with a foreach and accessing each object via the loop.</p>
  
  <p>This takes around 2 seconds to accomplish with C#.</p>
  
  <p>I am wondering if there is a faster way for me to accomplish this. I wrote some similar code in c++ a long time ago and it performed almost instantaneously, so i'm a bit disappointed that performance has suffered a bit in C#.</p>
  
  <p>Can i somehow speed things up with asynchronous code perhaps? Am i doing something in a less-than-optimal way?</p>
  
  <pre><code>foreach (Pixel p in my2Darray.Pixels) //this is a 2d array but we can still just loop through it with a single for loop
  {
      p.SetColor(Color.red);
  }
  </code></pre>