Code Snippets Local Functions

C# Local Functions

In this code snippet, we’ll take a look at local functions in C#.Local functions can be declared and used only within another function. This can be useful for organizing your code. For example, if a function gets too long, you would usually break it up into smaller ones, which will fragment your code. This is the perfect case for using local functions to logically group/contain these smaller functions within the parent function.

Calling The Command Line In C# With CliWrap

Calling The Command Line In C# With CliWrap

In this code snippet, we will learn how to call the command line in C#. We will be using a Nuget package called CliWrap which makes it easier compared to using the System.Diagnostics.Process class. But I will also show you how to use the Process class if you don’t want extra dependencies in your project. And it’s still a useful class as it can be used to run any executable (.exe file) from your C# code.

Code Snippets Using WebSockets In C#

Using WebSockets In C#

In this code snippet, we will learn how to use WebSockets in C#. WebSockets allow you to establish a bi-directional(full-duplex) communication channel over HTTP between two devices. This type of connection is long-lived and suitable for real-time data such as video streams, commands or inputs for a multiplayer video game.

Code Snippets Working With Streams In C#

Working With Streams In C#

In this code snippet, we will learn about streams in C#. Streams provide a generic view of a sequence of bytes. The Stream class is an abstract class that defines all the necessary things for any inheriting stream to implement such as Read(), Write(), Seek() and Flush() methods.

Advertisment ad adsense adlogger