title: How to create a property for a List<T>
body: <pre><code>private List&lt;T&gt; newList;
  
  public List&lt;T&gt; NewList
  {
  get{return newList;}
  set{newList = value;}
  }
  </code></pre>
  
  <p>I want to create something like this, but this is won't work. it's just an example to demonstrate my goal as it's pretty common creating proprties for string and int and even T but I've never seen a List property
  Is it even possible do such a thing, creating a property for type List ?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I have a normal class that has normal properties (string properties, int properties, etc) but I have this property that stores user options, So on the presentation layer I had to convert them into a string so I could be able to store them in the Object. Now is it possible to have a property of type List to store the multivalues in a better and clean way, instead of converting information into one string and then split it and again join it! Thanks Again =D</p>
  
  <p><strong>EDIT2</strong></p>
  
  <pre><code>private List&lt;KeyValuePair&lt;string, string&gt;&gt; _settings;
  
  public List&lt;KeyValuePair&lt;string, string&gt;&gt; MySettings
  {
      get { return _settings; }
      set { _settings = value; }
  }
  </code></pre>
  
  <p>I used the exact code you posted but the property still won't appear in the object's instance, so I tried adding code in the get and set (I wonder why you left them empty or does it means something?) and also added a private variable in the class but still it doesn't appear in the properties of the object's instance!</p>
  
  <p>I hope you could provide the exact code to implement this property and a simple code that assigns or retrieves from/to an instance of this class object
  It's the first time to even hear about this KeyValuePair and all the tutorials are pretty simple and not for my case, sorry!</p>
  
  <p><strong>The Last Edit: After a lot of researching and the help of Mark Avenius I found the perfect answer. hope everyone can benefit from this.</strong></p>
  
  <p><em><strong>NOW! HOW TO CREATE A PROPERTY FOR A LIST :</em></strong> </p>
  
  <blockquote>
    <p>The Options Class</p>
  </blockquote>
  
  <pre><code>Public Class Options
  {
          private string id;
          private int option;
  
          public int ID
          {
              get { return id; }
              set { id= value; }
          }
  
          public string Option
          {
              get { return option; }
              set { option = value; }
          }
  }
  </code></pre>
  
  <blockquote>
    <p>The Users Class</p>
  </blockquote>
  
  <pre><code>public class Users
  
  {
          private int userId;
          private string pass;
          private List&lt;Options&gt; userOptions = new List&lt;Options&gt;();
  
  
          public int ID
          {
              get { return userId; }
              set { user = userId; }
          }
  
          public string Pass
          {
              get { return pass; }
              set { pass = value; }
          }
  
          public List&lt;Options&gt; OptionsList
          {
              get { return userOptions; }
              set { userOptions = value; }
          }
  }
  </code></pre>
  
  <blockquote>
    <p>The Presentation Layer</p>
  </blockquote>
  
  <pre><code>    Users newUser = new Users ();
      Options userOption = new Options ();
  
      userOption.ID = int.Parse(txtBxID.Text);
      userOption.Option = txtBxOption.Text;
  
      Item.Options.Add(userOption);
  </code></pre>