Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Base c#

 class Person
     {
         public string Name { get; set; }
         public Person(string name)
         {
             Name = name;
         }
         public void Print()
         {
             Console.WriteLine(Name);
         }
     }

     class Employee : Person
     {
         public string Company { get; set; }
         public Employee(string name, string company): base(name)
         {
             Company = company;

         }
     }
     class Program
     {
         static void Main(string[] args)
         {
             Person person = new Person("Bob");
             person.Print();     // Bob
             Employee employee = new Employee("Tom", "Microsoft");
             employee.Print();   // Tom
         }
     }
 
PREVIOUS NEXT
Tagged: #Base
ADD COMMENT
Topic
Name
5+8 =