Adding Data to an Object

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5. using System.Threading.Tasks;  
  6. namespace TestingOops  
  7. {  
  8.    class Employee  
  9.    {  
  10.       public int Empage  
  11.       {  
  12.          getset;  
  13.       }  
  14.       public string Empname  
  15.       {  
  16.          get;set;  
  17.       }  
  18.       public string Empphonenumber  
  19.       {  
  20.          get;  
  21.          set;  
  22.       }  
  23.       public double Empsalary  
  24.       {  
  25.          get;  
  26.          set;  
  27.       }  
  28.    }  
  29.    class Program  
  30.    {  
  31.       static void Main(string[] args)  
  32.       {  
  33.          Employee emp = new Employee  
  34.          {  
  35.             Empage=32,  
  36.             Empname="Ujjwal",  
  37.             Empphonenumber="9031-214-542",  
  38.             Empsalary=50000  
  39.          };  
  40.          Console.WriteLine("Employee Name is : \'{0}\' and Age is {1}. {0} gets salary of $ {2} and his phone number is {3}",emp.Empname,emp.Empage,emp.Empsalary,emp.Empphonenumber);  
  41.          Console.ReadKey();  
  42.       }  
  43.    }  
  44. }