Initialization vs Instantiation in C#


Initialization

When you assign a value to a variable when it is declared, it is called Initialization.

Here is an example −

int val = 50;

For array initialization, you may need a new keyword, whereas to initialize a variable, you do not need it.

Instantiation

When you create a new object in C# for a class using the new keyword, then it is called instantiation.

Use the new operator to instantiate a class in C#.

Here is an example showing two objects of Student class created using new keyword −

Student s1 = new Student();
Student s2 = new Student();

Updated on: 30-Jul-2019

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements