Breaking News
Loading...
Friday 29 March 2013

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@\/  <(.'.)>

0 comments:

Post a Comment

Thanks for comment

 
Toggle Footer