Subpages

Abstract Classes in C# - Complete Guide

Properties vs Instance Variables in C# - Complete Guide


<aside> Classes are the foundation of object-oriented programming in C#. This guide covers essential concepts and best practices for working with classes.

</aside>

🔤 Classes are always named with a capital start letter

📝 Naming Conventions

When naming properties, always add an underscore before the name. Example below:

By default all created variables are private. By assigning them an underscore before the variable name you can set the access of the variable to public

namespace VacuumCleaner
{    
    public class VacuumCleanerClass
    {
        string _color;  //This is whats called an instance variable.
    }
}

Above example makes use of the public access modifier which means its accessible to anyone

📦 Instance Variables in C#

An instance variable is a variable that is declared inside a class but outside any method, constructor, or block. Each instance (object) of the class gets its own copy of these variables.

Key Characteristics: