title: How to call a field of child class in the method of parent class in C#
body: <p>I want to print the salary of invoked (any of them) child class in the inherited method of <code>Detail()</code>. this cannot be done in this scenario. How would I get the salary with all other details of an employee. </p>
  
  <p>Here is the code</p>
  
  <pre><code>using System;
  
  class Employee
  {
      public int ID;
      public string Name;
      public string Gender;
      public string City;
  
      public void Detail()
      {
          Console.WriteLine("Name: {0} \nGender: {1} \nCity: {2} \nID: {3}", Name, Gender, City, ID); //I want to get Yearly or Hourly Salary with these all
      }
  }
  
  class PermanatEmp : Employee
  {
      public float YearlySalary;
  
  }
  
  class TempEmp : Employee
  {
      public float HourlySalary;
  }
  
  
  
  class Class4
  {
      static void Main()
      {
          PermanatEmp pe = new PermanatEmp();
          pe.ID = 101;
          pe.Name = "XYZ";
          pe.Gender = "Male";
          pe.City = "London";
          pe.YearlySalary = 20000;
          pe.Detail(); // how to get Salary with these all 
  
  
      }
  
  }
  </code></pre>