C# Unchecked

In this code snippet, we’ll find out what the unchecked keyword does in C#. The unchecked keyword is used to suppress arithmetic overflow exceptions. We will try to add two integers whose sum will exceed the size of the integer data type. This will cause an overflow to occur. The overflow would normally throw an exception, but if we wrap the expression with unchecked the exception will get suppressed and the integer will just overflow.

Javascript Code Snippets Copying An Array

Copying Arrays in Javascript

In this post, we’ll learn how to copy an array in Javascript. In Javascript, if you assign an array to another array using the = assignment operator you won’t actually copy the values from one array into the other. What you will do is make another reference to the first array, so now you just have to variables pointing at the same array.

JS Code Snippets

Javascript Code Snippets

This post contains a list Javascript code snippets. In the code snippets, you can find Javascript related topics with a quick explanation and a code example. I made this collection of code snippets so that if I ever forget something I can just come here to refresh my memory.

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