title: Is it possible to access child class members that are not in parent class from a parent class type reference variable pointing to child class object?
body: <p>As per my understanding if I have a parent class type reference variable pointing to a child class object :</p>
  
  <pre><code>ParentClass obj= new ChildClass();
  
  obj.OnlyMembersThatHavebeenDerivedFromParentAreAvailable// am i wrong? 
  </code></pre>
  
  <p>In the below example which i have taken from <a href="http://csharp-video-tutorials.blogspot.in/2013/11/part-7-knowntype-attribute-in-wcf_24.html" rel="nofollow">click here</a>
  I should not be able to access AnnualSalary</p>
  
  <p><strong>Derived Class:</strong></p>
  
  <pre><code> public class FullTimeEmployee : Employee
      {
          public int AnnualSalary { get; set; }
      }
  </code></pre>
  
  <p><strong>Derived Class:</strong></p>
  
  <pre><code>public class PartTimeEmployee : Employee
      {
          public int HourlyPay { get; set; }
          public int HoursWorked { get; set; }
      }
  </code></pre>
  
  <p><strong>Parent Class</strong></p>
  
  <pre><code> public class Employee
      {
          private int _id;
          private string _name;
          private string _gender;
          private DateTime _dateOfBirth;
  
          [DataMember(Order = 1)]
          public int Id
          {
              get { return _id; }
              set { _id = value; }
          }
  
          [DataMember(Order = 2)]
          public string Name
          {
              get { return _name; }
              set { _name = value; }
          }
  
          [DataMember(Order = 3)]
          public string Gender
          {
              get { return _gender; }
              set { _gender = value; }
          }
  
          [DataMember(Order = 4)]
          public DateTime DateOfBirth
          {
              get { return _dateOfBirth; }
              set { _dateOfBirth = value; }
          }
  
          [DataMember(Order = 5)]
          public EmployeeType Type { get; set; }
      }
  </code></pre>
  
  <p><strong>How is the following code valid? :</strong></p>
  
  <pre><code>Employee employee = null;
   employee = new FullTimeEmployee
                          {
                              Id = Convert.ToInt32(reader["Id"]),
                              Name = reader["Name"].ToString(),
                              Gender = reader["Gender"].ToString(),
                              DateOfBirth = Convert.ToDateTime(reader["DateOfBirth"]),
                              Type = EmployeeType.FullTimeEmployee,
                              AnnualSalary = Convert.ToInt32(reader["AnnualSalary"]) // how is AnnualSalary available here? 
                          };
  </code></pre>