Object (C#)

An object is a concrete instance of a class, created at runtime with the new keyword. While a class is the blueprint, an object is an actual thing built from it that holds its own data.

C#

You can make many independent objects from the same class, each with its own values. You access an object's members with the dot operator, like dog.Name.

Every type in C# ultimately derives from the base type object (System.Object), so any value can be treated as an object.

Syntax

ClassName obj = new ClassName();

Examples

C#

class Point { public int X; public int Y; }

Point p = new Point { X = 2, Y = 5 };
Console.WriteLine($"{p.X}, {p.Y}");

Output:

2, 5

Learn it in a lesson

See also

Back to the Dictionary