What is Class and Object in C#.net ?


1). Class
•    Class is blue print or template in which object are created.
•    We can also say that class is collection of object.
•    If you want to use a class then you have to create an object.
•    Ex.  In our body the part call 'hand' is call class and we divide in two things like 'left hand' and 'right hand' this both is call its object
•    Ex.  Other example is bird in which we can say that bird is class and sparrow, parrot, duck etc. is calling its objects.


2). Object
•    Object is instance of class.
•    Object is showing the properties of class.
•    Group of object make class.

How to define class and its object.


public class Student
 {
            int RollNo=0;
            string Name="abc";

            public string getStudent()
            {
                return RollNo;
            }

            public void setStudent(int roll,string name)
            {
                RollNo = roll;
                Name = name;
            }
 }
public Static void main()
{
    // make its object
     Student objStudent = new Student();
            objStudent.getStudent();
            objStudent.setStudent(4, "Nirav Patel");
            objStudent.getStudent();
}

See Also :
  Follow Me On Facebook

--
/\/ir@\/  <(.'.)>

Comments

Popular posts from this blog

How to make and use web service in Microsoft Dynamics Navision.

How to use Format function in Microsoft Dynamics Navision.

How to create simple report in Microsoft Dynamics Navision.