C# Code Snippets Anonymous Methods

C# Anonymous Methods

In this code snippet, we’ll take a look at anonymous methods in C#. Anonymous methods don’t have names(obviously). They can be defined with the delegate keyword or by using the lambda expression. They can then be put into a variable of type delegate.

C# Code Snippets Abstract Keyword

C# Abstract Keyword

In this code snippet, we’ll find out what the abstract keyword does in C#. Classes and their members such as methods, properties, … that are marked with abstract keyword aren’t fully implemented. Abstract classes aren’t meant to be instantiated but are only meant to be inherited from. This means that class members(methods, properties, …) marked with the abstract keyword must be implemented in the child class.

C# Code Snippets Queue and Stack

C# Stacks And Queues

In this code snippet, we’ll take a look at queues and stacks in C#. Stacks and queues are similar to lists in the way that they don’t require their size to be declared on creation and elements can be dynamically added or removed. In fact, all of the above(queues, stacks, and lists) are part of the same collections namespace and they implement some of the same interfaces. 

C# Code Snippets List

C# List

In this code snippet, we’ll find out how to use lists in C#. Lists are similar to arrays, but unlike arrays, you can add and remove items from lists without having to destroy the entire list and making a new one. Also, lists have a lot of useful methods such as find(), exists(), sort(), …  You can use intellisense in Visual Studio to explore all the methods available.

C# Code Snippets Dictionary

C# Dictionary

In this code snippet, we’ll take a look at dictionaries in C#.
Dictionaries can hold a collection of objects and are similar to lists. But unlike lists, the objects stored in the dictionary are paired with a key. That key can be used to access the object in the collection.

C# Code Snippets Iteration

C# Iteration

In this code snippet, we’ll find out how to iterate with the for, foreach, while and do while loop. What loops do is execute the code in their curly brackets(multiple times, maybe only once or even never). The number of times that they will do that depends on the condition that will get evaluated at the beginning of each iteration. Usually, the condition consists of the maximum number of iterations and the counter variable which contains the number of iterations so far. The counter is an integer that gets increased at the end of the loop. This way we can keep track of how many iterations were performed. 

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.

Advertisment ad adsense adlogger