C# Classes and Objects

hi
i don’t hardstand the meaning of Classes and Objects .
what is object?
what is the difference between a object and a Variables ?

from this lecture…
Classes and Objects

EDIT
Introduction to Classes and Objects
I think this video explain it very well
tanks.

Hi,

I did not enroll to that course.

Classes are like templates to object instances
An object may include variables or be identified by one.

Say I have a Person class

public class Person
{
  public string Name {get; set;}
  public byte Age {get; set;}
}

I can create Person objects out of the Person class.

Person person = new Person{Name="Shalom", Age=30};

Person is the type. It means the object will follow the Person class template
person is often simply called variable name (or variable for short) but you may meet other terms such as identifier or handle.

The statement after the equal sign is calling a constructor. It uses Object Initializer syntax here. It results in the creation of an object being an instance of the Person class.

Cheers.

2 Likes

Hi,
classes are nothing more than blueprints that describe what an object will be. Fields and methods are defined in the class, but no memory is allocated. An object is an instance of a class, when you instantiate an object memory is allocated and all fields and methods of the class are accessible.

2 Likes