C# Code Snippets C# Struct

C# Struct

In this code snippet, we’ll make a struct in C#. A struct is like a lightweight class. You would use a struct for making a small object that doesn’t have a lot of members. If your struct grows too big(has too many properties/methods) you should make a class instead.

C# Code Snippets Sealed Keyword

C# Sealed Keyword

In this code snippet, we’ll take a look at the sealed keyword in C#.
In the following example, we will make a sealed class and a sealed method. Then we’ll try inheriting from the sealed class and overriding the sealed method. As you will be able to see we’ll get an error as sealed methods can’t be overridden and sealed classes can’t be inherited from.

Advertisment ad adsense adlogger