C# implementation of class and object
Program.cs
Console.WriteLine("———————————————————————————————————————————");
Console.WriteLine("Program to use the class and object");
Console.WriteLine("———————————————————————————————————————————");
Computer c = new Computer();
c.insert("Wireless","Lenovo",145221);
c.display();
Console.WriteLine("———————————————————————————————————————————");

public class Computer
{
    public String mouseType = "";
    public String mouseCmp = "";
    public int mouseId;

    public void insert(String t,String c,int i)
    {
        mouseType = t;
        mouseCmp = c;
        mouseId = i;
    }
    public void display()
    {
        Console.WriteLine("Mouse Type: "+mouseType+"\nMouse Cmp:  "+mouseCmp+"\nMouse Id:   "+mouseId);
    }
}
Output
kodingwindow@kw:~/csharp$ dotnet run
———————————————————————————————————————————
Program to use the class and object
———————————————————————————————————————————
Mouse Type: Wireless
Mouse Cmp:  Lenovo
Mouse Id:   145221
———————————————————————————————————————————
kodingwindow@kw:~/csharp$ 
Advertisement