C# Code Snippets

C# Code Snippets

This post contains a collection of C# related things I learned and projects I did. The C# Code Snippets section is where you can find C# and .NET related topics like decision statements, Object-Oriented programming in C#, Threading, Events, Collections, … Meanwhile, under Algorithms and useful bits of code you will be able to find such things as sorting algorithms, quick how-tos, and other useful bits of code that don’t really fit anywhere else. And finally, there is the C# Project section that has my C# projects.

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