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.

DIY Current Clamp Meter

DIY Clamp Current Meter

In this post, I will show you the contactless clamp power meter I made. I used a readily available SCT-013 current transformer clamp. The great thing about this is that you can measure the current flowing through a wire without having to put an amp meter in series with the load and source. This means you also don’t have to expose yourself to a potentially dangerous voltage.

ESP OTA

ESP32/8266 Over The Air Updates (OTA)

In this post, I’ll show you how to do OTA(over the air updates) to your ESP32/ESP8266. This means that you don’t have to connect your ESP board to your PC by cable and can instead push firmware updates wirelessly over the network(as long as you are connected to the same network). The process of uploading the firmware remains almost the same. The only difference is you have to select a network port under Tools -> Port -> Network Ports instead of a COM port.

Visual Studio on localhost

Test Local Website on Smartphone While Developing In Visual Studio

In this post, I will show you how to access a local website running on localhost(Windows). Specifically, I will show you how to do this for Visual Studio when you are running/debugging your web app/server during development.

This can be very useful for checking if your website works properly on mobile and allows other people(within your network, unless you port forward) to test your site without having to deploy your site on some remote dev./test server.

GDS Viewer

Online GDS File Viewer

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.

Advertisment ad adsense adlogger