Home / Programs / C# Object and Class Example, Store and Display Employee Information
🚀 Programming Example

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

👁 649 Views
💻 Practical Program
📘 Step Learning
Let us see an example of C# Object and Class where it store and display Employee Information.

💻 Program Code

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();  
  
        }  
    }  
                        

🖥 Program Output

1011 Rambo 880000
1022 Azmi 440000
                            

📘 Explanation

None
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.