In this post, I’ll talk about the online GDS File Viewer/Editor I made(or I’m making as it’s still a work in progress). For now, I will make the development version of the app available online so people can find it and test it. Eventually, I will post the code on Github but first I want to add some more features, refactor the code and maybe write some unit tests.
In this code snippet, we will take a look at bitwise operators in C#. Bitwise operators can be used to manipulate individual bits of a variable. These operations can be quite cryptic and hard to understand compared to regular code. So only use it when it makes sense(for example bit masking) and don’t prematurely optimize your code. In C# we can use enums in conjunction with the Flags attribute to do bitmasking. This gives us cleaner and more readable code.
In this code snippet, we will take a look at pattern matching in C#. Pattern matching is simply testing if an expression matches certain criteria. For example, Regex often times gets used for more complex pattern matching of strings.
In this code snippet, we will take a look at the nullable types, null coalescing and checking operators in C#. Reference types are nullable by default, value types like int for example are not. You can make them nullable by appending ? after the data type declaration like so: int?
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.
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
In this code snippet, we’ll see how to benchmark C# code. Benchmarking can be useful to find out how well a certain piece of code is performing. We can look at how much time it takes to execute it and how much memory gets used in the process.
In this code snippet, we will take a look at tuples in C#. Tuples allow you to quickly and easily create objects. You can for example use them as a variable or method return data type.
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.
In this code snippet, we will take a look at boxing and unboxing in C#. Boxing happens when a value data type is converted to an object while unboxing is when that object gets converted back into a value.