title: 2D-array as a class property - how to create them the C# way?
body: <p>I am trying to create a class with a property that is a two-dimensional array. The array will hold various x,y coordinates on a grid (e.g. 0,1 or 3,7) and the size of the array is dependent on a class property called size.</p>
  
  <p>How would you go about creating this array in C#? I have given my solution below, but having very little C# experience and coming from a Python background with some javascript knowledge, it feels like that there is a better solution to this problem. </p>
  
  <p>Could one of you C# wizards enlighten me, please?</p>
  
  <p>Thanks in advance for your help.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class Obj
  {
      int Size;  // Defines length of array
      int[,] Pos;
  
      // constructor
      public Obj(int size)
      {
          this.Size = size;
          this.Pos = new int[size, 2];
      }
  
      public void set_coord(int index, int x, int y)
      {
          if (index &gt;= this.Size) {
              Console.WriteLine("Catch OutOfRangeException");
          }
          else
          {
              this.Pos[index, 0] = x;
              this.Pos[index, 1] = y;
          }
      }
  </code></pre>