Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C# Classes

Overview

Types are reference types. They are stored in the heap memory.

You create objects/instances by using the new keyword. The variables that you use to create the instance of the type stores only the reference to the object in the memory. The reference itself is stored in the stack memory.

Fields and Properties Initialisation

You can initialise the fields and properties of types in the following ways:

Way Description
Field Initialiser Set a default value for a field or property
Constructor Parameter Write a constructor method
Primary Constructor Use the same syntax for accepting parameters as for methods

required keyword

Used to make a property or field mandatory for the user of the class to initialise it.

  
    public required string FirstName { get; set; }
  

Static classes

Static classes can't be instantiated and can only contain static members. Can be used for extra functions that don't require instances of that class.

Class Access Modifiers

  • internal - used as the default. The class only exists for the current assembly.
  • public - the class becomes available to other assemblies.

About

C# classes practice.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages