Have you failed a job interview?
Send us your job interview questions and get correct answers.

What is a class instance in C#?

Experience Level: Junior
Tags: C#

Answer

In C#, a class instance is an object that was created based on the class.

The class is like a recipe that defines a logic how to cook a meal. The meal prepared by a recipe is then called a class instance. Or an object.

In the following program there is a class Dog defined. Based on this class 3 dog objects are created. We are saying that we have created 3 instances of class Dog.

Example
using System;

namespace MyApp {
  class Program {
    static void Main() {
      var dog1 = new Dog();
      var dog2 = new Dog();
      var dog3 = new Dog();
    }
  }

  class Dog {
  }
}

Comments

No Comments Yet.
Be the first to tell us what you think.
C# for beginners
C# for beginners

Are you learning C# ? Try our test we designed to help you progress faster.

Test yourself