C#

How can I use async with foreach in C#

This blog post will show you how to await the foreach loop in C#. Onwards c#, we can use async foreach in our code. To use async foreach, your method must return IAsyncEnumerable<T>. Let’s understand it with one example…

RSA encryption/decryption C# example

There are two classes for asymmetric encryption in .net. RSACryptoServiceProvider and DSACryptoserviceProvider . With the default constructor, both classes automatically create the public and private keys necessary to encryption…

How to extract number from string using Linq

Imagine you have an s tring("ABCDE99F-J74-12-89A") , and you want to extract the only number from the string. This snippet will show how to extract numbers from strings. using System ; using System . Collections . G…

C# Boyer-Moore String Search Example

In this article, I will show you the implementation of the ==Boyer-Moore == algorithm. Boyer Moore is a string searching algorithm. It avoids checking most positions in the source string. The implementation here uses constant ch…

Delete node from linked list with specific value

In computer science, a linked list is a linear collection of data elements whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collecti…

Measure The Performance Of Your .NET Code Using BenchmarkDotNet

As developers, we are sometimes challenged with making a specific piece of code run quicker. We frequently need to pick which piece of code performs the best. Benchmarking gives us concrete measurements between different portion…

Encrypt and Decrypt a String in C# Using Asymmetric Encryption

There are two classes for asymmetric encryption in .net. RSACryptoServiceProvider and DSACryptoserviceProvider . Both classes automatically create the public and private keys necessary to encryption and decryption with the defau…

C# Program To Print All the IP Addresses of the Given Website

In this code snippet, I will show you how to print all the IPV4 addresses of any website using C#. For this, you have to call the static method GetHostAddressesAsync on Dns class. It will return an Array of IPAddress . Check o…

Disposal and garbage collection in C#

Object lifetime in C# What new keyword does? Allocate Objects onto one of two heaps How Garbage collection works? The System.GC type How to avoid Memory Leak? Building Disposable Object Finalizer (+ Freachable) Queue …

Iterating One Dimensional Array As Two Dimensional Array-C#

This article will show you how to store a 2D array as a 1D array in C#. (This technique can be applied to any language). 2D Row: 1 Col: 1 Row: 1 Col: 2 Row: 1 Col: 3 Row: 2 Col: 1 Row: 2 Col: 2 Row: 2 Col: 3 …

Best Practice for Using HttpClient-C#

Best Practice for Using HttpClient-C# Almost every application nowadays is making HttpRequest get data from other services. In this article, I will share some best practices for using the .net core HttpClient API. To understan…

تحميل المزيد من المشاركات
لم يتم العثور على أي نتائج