title: Defining a bit[] array in C#
body: <p>currently im working on a solution for a prime-number calculator/checker. The algorythm is already working and verry efficient (0,359 seconds for the first 9012330 primes). Here is a part of the upper region where everything is declared:</p>
  
  <pre><code>const uint anz = 50000000;
  
  
  uint a = 3, b = 4, c = 3, d = 13, e = 12, f = 13, g = 28, h = 32;
  bool[,] prim = new bool[8, anz / 10];
  uint max = 3 * (uint)(anz / (Math.Log(anz) - 1.08366));
  uint[] p = new uint[max];
  </code></pre>
  
  <p>Now I wanted to go to the next level and use ulong's instead of uint's to cover a larger area (you can see that already), where i tapped into my problem: the bool-array.
  Like everybody should know, bool's have the length of a byte what takes a lot of memory when creating the array... So I'm searching for a more resource-friendly way to do that.
  My first idea was a bit-array -> not byte! &lt;- to save the bool's, but haven't figured out how to do that by now. So if someone ever did something like this, I would appreciate any kind of tips and solutions. Thanks in advance :)</p>