title: Validation with setter when creating object with constructor through method
body: <p>I have an object of Person that is created with a method, inside the method i use my constructor to create the object. I have some validation for the gender in my setter, but I can't see how i make it use my setter? </p>
  
  <pre><code>class Person
      {
          public string name;
          public int age;
          private string gender;
          private static List&lt;Person&gt; Personlist = new List&lt;Person&gt;();
  
          public Person(string _name, int _age, string _gender)
          {
              this.name = _name;
              this.age = _age;
              this.Gender = _gender;
  
          }
  
          public string Gender
          {
  
              get { return gender; }
              set
              {
                  //value = de doorgegeven data
                  if (value == "m" || value == "v")
                  {
                      gender = value;
                  }else
                  {
                      gender = "Error: not a valid gender!";
                  }
              }
          }
          public static void addPerson(string name, int age, string _gender){
              Personlist.Add(new Person(name, age, _gender));
          }
  </code></pre>
  
  <pre><code>class Program
      {
          static void Main(string[] args)
          {
              Console.WriteLine("Geef de naam van de persoon: ");
              var name = Console.ReadLine();
              Console.WriteLine("Geef de leeftijd van de persoon: ");
              var age = Convert.ToInt32(Console.ReadLine());
              Console.WriteLine("Geef het geslacht van de persoon [MOET 'v' OF 'm' ZIJN]: ");
              var gender = Console.ReadLine();
  
  
  
              Person.addPerson(name, age, gender);
              Person.speek(name, age, gender);
  
          }
      }
  
  </code></pre>