C# Code Snippets Records

C# Records

In this code snippet, we will take a look at records in C#. Records can be used instead of classes and structs. They reduce the amount of boilerplate code required to create objects whose purpose is to simply hold data. By default, records are reference types just like classes but they will act like value types when compared for equality(using == operator) meaning that two different records will be evaluated as the same if all their values are the same.

C# Code Snippets Readonly

C# Readonly

In this code snippet, we will take a look at the readonly keyword in C#. Obviously, a variable/field marked as readonly can not be modified after it was set. However, readonly can be set at run time in the constructor or when it’s declared(at compile time) unlike const which can only be set at compile

C# Code Snippets Ranges

C# Ranges

In this code snippet, we will take a look at ranges in C#. Ranges give you a quick and easy syntax to get a range/interval of elements from a collection. For example, if an array has 10 elements you can specify a range from the 2nd to the 5th element and that slice of the array will be returned to you.

C# Code Snippets DateTime

C# DateTime

In this code snippet, we will take a look at DateTime in C#. DateTime is used to represent dates and times in code. The DateTime class contains many useful methods to manipulate the date(formatting the date, adding/subtracting years, months, days, hours, …). Let’s have a look at the code below to see how to use DateTime.

Code Snippets JS 2D Library Konva.js

Javascript 2D Library Konva.js

In this post, we’ll take a look at the Konva.js. Konva is a pretty nice 2D javascript graphics library for the browser. I discovered it when I needed a 2D library for a project at work. It supports both Vue and React frameworks. The reason a library is useful compared to just drawing objects on a canvas is that it provides you with an easy way to draw, style, find, manipulate and attach events to objects.

Advertisment ad adsense adlogger