C# Object and Class Example, Store and Display Employee Information

C# Programming Language / OOPS Concept

607

Program:

using System;  
   public class Employee  
    {  
        public int id;   
        public String name;  
        public float salary;  
        public void insert(int i, String n,float s)  
        {  
            id = i;  
            name = n;  
            salary = s;  
        }  
        public void display()  
        {  
            Console.WriteLine(id + " " + name+" "+salary);  
        }  
   }  
   class TestEmployee{  
       public static void Main(string[] args)  
        {  
            Employee e1 = new Employee();  
            Employee e2 = new Employee();  
            e1.insert(1011, "Rambo",880000f);  
            e2.insert(1022, "Azmi", 440000f);  
            e1.display();  
            e2.display();  
  
        }  
    }  

Output:

1011 Rambo 880000
1022 Azmi 440000

Explanation:

None

This Particular section is dedicated to Programs only. If you want learn more about C# Programming Language. Then you can visit below links to get more depth on this subject.