Advertisement
Obada8

Example on overloading construction on c#

Jan 28th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. namespace Inheritance
  5. {
  6.     public class Employee
  7.     {
  8.  
  9.         public Employee(string A1, string A2) : this(0, 0, 0, 0)
  10.         {
  11.             Console.WriteLine(A1.ToString() + " hi " + A2.ToString() );
  12.         }
  13.  
  14.         public Employee(string B1, string B2, string B3) :this ("No Information", "No Information")
  15.         {
  16.             Console.WriteLine(B1+" hi"+B2+" hi"+B3);
  17.         }
  18.  
  19.         public Employee(int A1, int A2, int B1, int B2)
  20.         {
  21.             Console.WriteLine(A1.ToString() + A2.ToString() + B1.ToString() + B2.ToString());
  22.         }
  23.  
  24.  
  25.         public Employee() : this("No Information", "No Information")
  26.         {
  27.  
  28.         }
  29.  
  30.         ~Employee()
  31.         {
  32.  
  33.         }
  34.     }
  35.  
  36.     class Program
  37.     {
  38.         static void Main()
  39.         {
  40.             Employee e = new Employee();
  41.             Console.Read();
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement