Class: Class Contains Data members for storing data and member function to perform action on that data.
Object: Its class variable. Used to access class methods.
Example:
using System;
namespace ClassObject {
class Dog {
string breed;
public void bark() {
Console.WriteLine("Bark Bark !!");
}
static void Main(string[] args) {
// create Dog object
Dog bullDog = new Dog();
// access breed of the Dog
bullDog.breed = "Bull Dog";
Console.WriteLine(bullDog.breed);
// access method of the Dog
bullDog.bark();
Console.ReadLine();
}
}
}
Happy Coding!
Thanks.
0 Comments
If you have any queries, please let me know. Thanks.