# C# Classes and Objects

**URL:** <https://forum.codewithmosh.com/t/c-classes-and-objects/18045>\
**Category:** C#\
**Created:** [February 1, 2023, 6:07pm UTC](https://forum.codewithmosh.com/t/c-classes-and-objects/18045 "2023-02-01T18:07:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shalom](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/shalom/32/5530_2.png) [@shalom](https://forum.codewithmosh.com/u/shalom)\
**Post date:** [February 1, 2023, 6:07pm UTC](https://forum.codewithmosh.com/t/c-classes-and-objects/18045/1 "2023-02-01T18:07:19Z")

</div>

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](https://codewithmosh.com/courses/223623/lectures/3481523)

**EDIT**  
[Introduction to Classes and Objects](https://youtu.be/8yjkWGRlUmY)  
I think this video explain it very well  
tanks.

---

<div class="post-metadata">

**Author:** ![UniqueNospaceShort](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/uniquenospaceshort/32/1814_2.png) [@UniqueNospaceShort](https://forum.codewithmosh.com/u/UniqueNospaceShort)\
**Post date:** [February 1, 2023, 9:01pm UTC](https://forum.codewithmosh.com/t/c-classes-and-objects/18045/2 "2023-02-01T21:01:22Z")

</div>

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

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

```

I can create Person objects out of the Person class.

```auto
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.

---

<div class="post-metadata">

**Author:** ![Makfava](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/makfava/32/5646_2.png) [@Makfava](https://forum.codewithmosh.com/u/Makfava)\
**Post date:** [February 24, 2023, 2:57pm UTC](https://forum.codewithmosh.com/t/c-classes-and-objects/18045/3 "2023-02-24T14:57:25Z")

</div>

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.
