title: Properties exposing array elements in C#
body: <p>I want to create a property in C# that sets or returns an individual member of an array.  Currently, I have this:</p>
  
  <pre><code>private string[] myProperty;
  public string MyProperty[int idx]
  {
      get
      {
          if (myProperty == null)
              myProperty = new String[2];
  
          return myProperty[idx];
      }
      set
      {
          myProperty[idx] = value;
      }
  }
  </code></pre>
  
  <p>However, I get the following compile error:</p>
  
  <blockquote>
    <p>Bad array declarator: To declare a managed array the rank specifier precedes the variable's identifier. To declare a fixed size buffer field, use the fixed keyword before the field type.</p>
  </blockquote>