C# Covariance And Contravariance
In this code snippet, we’ll take a look at covariance and contravariance in C#.Covariance and contravariance enable implicit type conversion for arrays, delegates and generic interface type arguments.
In this code snippet, we’ll take a look at covariance and contravariance in C#.Covariance and contravariance enable implicit type conversion for arrays, delegates and generic interface type arguments.
In this code snippet, we’ll see how to do image classification in C# using the ML.NET machine learning framework. It provides a user friendly GUI for creating, training and deploying different kinds of machine learning models within Visual Studio. It makes it very quick and easy to add machine learning to your .NET projects.
In this code snippet, we’ll see how to use GPU acceleration in C# using the ILGPU library. ILGPU provides you with a fairly simple interface to run code on your GPU from C#. For more information, you can check out the official documentation here. In this post, I will show you how to do some image processing by utilizing GPU acceleration if you want to see more examples(simpler or more complex ones) you can find them here.
In this code snippet, we will take a look at COM objects, interop using PInvoke and type marshalling in C#.
In this code snippet, we will take a look at lambda expressions, Func
In this code snippet, we will take a look at unsafe code, pointers, stack allocation and spans in C#. C# has managed memory unlike for example C/C++. This means that you don’t have to allocate or clear memory by yourself and in the case of .NET the CLR(common language runtime) takes care of memory allocation and garbage collection. This also means that in C# you can’t work with a pointer or allocate your variables on the stack which is common practice in C/C++.
In this code snippet, we will take a look at async and await in C#.
The aysnc keyword enables a method to use the await keyword. These two keywords together enable us to execute code asynchronously. When called an async method will return a Task.
In this code snippet, we will learn how to do some basic queries using LINQ(Language Integrated Query) in C#.LINQ is used to work with data within C# and can be used on enumerable types(IEnumerable
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.