title: C# Arrays as Class Properties
body: <p>I searched a lot but couldn't find any solution. I am probably using the wrong keywords. I have a class which is basically an extended version of ListView control.</p>
  
  <p>I defined some custom attributes for my customized ListView, such as FileName, OrderType etc, and they work fine.</p>
  
  <p>I also want to pass an array to my class which includes ColumnNames to populate the data within class.</p>
  
  <p>In <code>MyListView</code> Class</p>
  
  <pre><code>public class ColumnNames : Attribute
  {
      public string[] Values { get; set; }
  
      public ColumnNames(params string[] values)
      {
          this.Values = values;
      }
  }
  
  [ColumnNames("a1","a2","a3","a4","a5","a6","a7","a8","a9")]
  
  public MyListView() {
  
       for (int i = 0; i &lt; 7; i++)
              this.Columns.Add(this.ColumnNames[i]);
  
      }
  </code></pre>
  
  <p>In <code>Form1</code> Class</p>
  
  <pre><code>MyListView lstv = new MyListView();
  
  lstv.ColumnNames[0] = "hede1";
  lstv.ColumnNames[1] = "hede2";
  lstv.ColumnNames[2] = "hede3";
  </code></pre>
  
  <p><strong>EDIT :</strong> I simply couldn't achieve what I wanted. Could you show me a working example of this?</p>
  
  <p>I use this listview to display information taken from a database. (I use ListView instead of DataGrid) I want to pass the column names to this class which will be used both for SQL query "SELECT xxxxx, yyyyy, zzzz FROM table;" and column names this.columns.add("xxxxx"); this.columns.add("yyyyy"); this.columns.add("zzzzz");</p>