C# Code Snippets Image Classification With ML.NET

C# Image Classification With ML.NET

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.

C# Code Snippets GPU Acceleration For Your C# App With ILGPU

GPU Acceleration For Your C# App With ILGPU

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.

C# Code Snippets Func Action Lambda

C# Lambda Expressions

In this code snippet, we will take a look at lambda expressions, Func and Action in C#.Func is simply a more compact way of defining a delegate/function pointer while Action is the exact same thing as Func but for methods that return void. The lambda operator () => is a more compact way to define an anonymous method that can then be assigned to a delegate or passed into another method as a parameter. It’s very often combined with LINQ to form very concise queries that all fit into a single line of code.

C# Code Snippets Unsfe code Pointers Stackalloc and Spans

C# Unsafe code, Pointers, Stackalloc and Spans

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++.

C# Code Snippets LINQ Basics

C# LINQ Basics

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 or IQueryable interface) like lists, arrays, … A query can be made by using an SQL query like syntax or by method chaining. The latter is often combined with the lambda operator to specify some kind of condition as the parameter to the function/method.

C# Code Snippets Bitwise Operators

C# Bitwise Operators

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.

C# Code Snippets Pattern matching

C# Pattern Matching

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. 

Advertisment ad adsense adlogger