Class:
- Class is group of objects that share common properties and relationships.
- Class members are private by default.
- Classes are reference type that is they are stored on heap
- Class can be inherited and but can be instantiated
Class Employee
{
public in CustID;
public in CustName;
}
Structure:
- Structure is collection of different types of data types.
- Structure embers are public by default
- Structure are value type that is they are stored on stack
- Structure can not be inherited but can be instantiated
Struct Employee
{
public int CustID;
public string name;
}
Object:
- Object is basic runtime entity OR object is instance of class.
- Object consistsof data and function together
- Object allows designing systems that are more robust and portable through the proper application of abstraction
public class Student
{
public string First_Name { get; set; }
public int Weight { get; set; }
public Person(string First_Name, int Weight)
{
First_Name = first_Name;
Weight = weight;
}
//Other properties, methods, events...
}
class Program
{
static void Main()
{
Student person1 = new Student("Anil", 66);
Console.WriteLine("Student First_Name = {0} Weight = {1}", person1.First_Name, person1.Weight);
}
}
Output:Student First_Name = Anil Weight = 66
Comments
Post a Comment