current location:Home > Technical Articles > Backend Development > C#.Net Tutorial

  • How to write retry logic in C#?
    How to write retry logic in C#?
    Whenever an operation fails, retry logic is implemented. Implement retries to only log logic in the full context of the failed operation. It is important to log all connection failures that result in retries so that underlying issues with the application, service, or resource can be identified. Example classProgram{ publicstaticvoidMain(){ HttpClientclient=newHttpClient(); dynamicres=null;&
    C#.Net Tutorial 1370 2023-09-24 12:45:03
  • How to create an array with non-default repeating values ​​in C#?
    How to create an array with non-default repeating values ​​in C#?
    We can use Enumerable.Repeat() to create an array with non-default values. It repeats a collection containing repeated elements in C#. First, set which element you want to repeat how many times. Example 1classProgram{ staticvoidMain(string[]args){ varvalues=Enumerable.Repeat(10,5); foreach(varitem
    C#.Net Tutorial 1169 2023-09-23 22:45:06
  • What operators does C# provide to handle null values?
    What operators does C# provide to handle null values?
    C# has the following three operators to handle null values ​​- The null coalescing operator (??) allows you to get the value of a variable if it is not null, or specify a default value that can be used. It replaces the following expression in C# - stringresultOne=value!=null?value:"default_value"; with the following expression - stringresultTwo=value??"default_value"; Here is an example illustrating this. Example usingSystem;classProgram{ s
    C#.Net Tutorial 1165 2023-09-23 17:57:02
  • Looping techniques in C#
    Looping techniques in C#
    Loop statements allow us to execute a statement or a group of statements multiple times. The following are the loops supported by C# - Sr.No. Loop types and descriptions 1while loop When a given condition is true, it repeats a statement or a group of statements. It tests the condition before executing the loop body. 2for loop It executes a series of statements multiple times and abbreviates the code that manages the loop variables. 3do...while loop It is similar to the while statement, except that it tests the condition at the end of the loop body. Using C#, you can also use a foreach loop as shown below - example usingSystem;usingSystem.Collections;classDemo{ &n
    C#.Net Tutorial 675 2023-09-23 15:41:06
  • C# OfType() method
    C# OfType() method
    Filter the collection based on each element type. Suppose you have the following list containing integer and string elements - list.Add("Katie"); list.Add(100); list.Add(200); Filter the collection and get only the elements of string type. varmyStr=fromainlist.OfType<string>()selecta; works the same way for integer types. varmyInt=fromainlist.OfType<int>()selecta;The following is the complete code-example real-time demonstration usingSystem;usi
    C#.Net Tutorial 1339 2023-09-23 13:41:08
  • How to truncate a file in C#?
    How to truncate a file in C#?
    To truncate a file in C#, use the FileStream.SetLength method. The following is the syntax - publicoverridevoidSetLength(longvalue); here, int64 = the length value of the stream
    C#.Net Tutorial 1440 2023-09-23 12:21:03
  • How to determine if a string contains all unique characters using C#?
    How to determine if a string contains all unique characters using C#?
    To determine if a string has unique characters, first check that the word in the string matches the next word - for(intj=i+1;j<val.Length;j++){ if(val[i]==val[j] )} If a match is found, it means that the string does not contain unique characters. If no match is found, the string contains all unique characters. If it matches, return false, that is, the unique character is not found -for(intj=i+1;j<val.Length;j++){ if(val[i]==val[j])&a
    C#.Net Tutorial 1256 2023-09-23 11:17:02
  • C# program to add two time spans
    C# program to add two time spans
    First, set up two TimeSpans - TimeSpant1=TimeSpan.FromMinutes(1); TimeSpant2=TimeSpan.FromMinutes(2); To add it, use the Add() method - TimeSpanres=t1.Add(t2); Example UsingSystem; usingSystem. Linq;publicclassDemo{ publicstaticvoidMain(){ TimeS
    C#.Net Tutorial 1127 2023-09-23 10:05:06
  • C# program to sort a list of string names using the LINQ OrderBy() method
    C# program to sort a list of string names using the LINQ OrderBy() method
    Sorting a list of string names is a common task in programming, and the LINQOrderBy() method in C# provides a simple and efficient way to perform this operation. In this article, we will walk you through a C# program to sort a list of string names using the LINQOrderBy() method. What is the LINQOrderBy() method? The LINQOrderBy() method is used to sort the elements in a sequence in ascending or descending order based on one or more keys. Keys can be simple properties or complex expressions that return a value based on one or more properties of the objects in the sequence. Syntax of OrderBy() method publicstaticIO
    C#.Net Tutorial 1267 2023-09-22 23:57:03
  • Main features of C# programming
    Main features of C# programming
    C# is a modern, general-purpose object-oriented programming language developed by Microsoft. C# is designed for use with the Common Language Infrastructure (CLI), which consists of executable code and a runtime environment that allows the use of a variety of high-level languages ​​on different computer platforms and architectures. Following are the main features of C#: Here is a list of few important features of C#: Boolean conditionals Automatic garbage collection Standard library Assembly version control Properties and event delegation and event management Easy to use generic indexer Conditional compilation Simple multi-threaded LINQ and Lambda expression integration with Windows
    C#.Net Tutorial 846 2023-09-22 23:33:12
  • Print single and multiple variables in C#
    Print single and multiple variables in C#
    To display a single variable value in C#, just use Console.WriteLine() Let’s see an example. Here we are displaying the value of a single variable "a" in a single line - example usingSystem;usingSystem.Linq;classProgram{ staticvoidMain(){ inta=10; Console.WriteLine("Value:&qu
    C#.Net Tutorial 826 2023-09-22 21:57:03
  • How to easily initialize a list of tuples in C#?
    How to easily initialize a list of tuples in C#?
    Tuples can be used when you want a data structure to hold an object with properties, but don't want to create a separate type for it. The Tuple class was introduced in .NET Framework 4.0. A tuple is a data structure that contains a sequence of elements of different data types. Tuple<int,string,string>person=newTuple<int,string,string>(1,"Test","Test1");A tuple can only contain up to eight elements. It gives compiler error when you try to include more than eight elements. list tuple var
    C#.Net Tutorial 1325 2023-09-22 17:33:07
  • C# program to check if a string contains special characters
    C# program to check if a string contains special characters
    To check if a string contains special characters you need to use the following method - Char.IsLetterOrDigit use it in a for loop and check if the string contains special characters. Suppose our string is - stringstr="Amit$#%"; Now convert the string to character array - str.ToCharArray(); Use for loop and check each character using isLetterOrDigit() method. Example Let's look at the complete code. Live demonstration usingSystem;namespaceDemo{ classmyA
    C#.Net Tutorial 1622 2023-09-22 16:57:03
  • C# program to sort a list of employees whose department is XYZ based on salary in descending order using LINQ
    C# program to sort a list of employees whose department is XYZ based on salary in descending order using LINQ
    In C#, LINQ (Language Integrated Query) is a powerful tool that allows you to sort, filter and manipulate data easily. In this article, we will demonstrate how to use LINQ to sort a list of employees in descending order based on their salary and job department. Sorting a list of employees based on salary in descending order and their department is set;}publicintSalary{get;set;}publicstringDe
    C#.Net Tutorial 1136 2023-09-22 16:45:08
  • How to find all unique quadruples close to zero using C#?
    How to find all unique quadruples close to zero using C#?
    The simplest way is that we can create four nested loops and check one by one whether the sum of all four elements is zero. If the sum of the four elements is zero, print the elements. Time complexity-O(n4)
    C#.Net Tutorial 1047 2023-09-22 15:37:02

Tool Recommendations

jQuery enterprise message form contact code

jQuery enterprise message form contact code is a simple and practical enterprise message form and contact us introduction page code.
form button
2024-02-29

HTML5 MP3 music box playback effects

HTML5 MP3 music box playback special effect is an mp3 music player based on HTML5 css3 to create cute music box emoticons and click the switch button.

HTML5 cool particle animation navigation menu special effects

HTML5 cool particle animation navigation menu special effect is a special effect that changes color when the navigation menu is hovered by the mouse.
Menu navigation
2024-02-29

jQuery visual form drag and drop editing code

jQuery visual form drag and drop editing code is a visual form based on jQuery and bootstrap framework.
form button
2024-02-29

Organic fruit and vegetable supplier web template Bootstrap5

An organic fruit and vegetable supplier web template-Bootstrap5
Bootstrap template
2023-02-03

Bootstrap3 multifunctional data information background management responsive web page template-Novus

Bootstrap3 multifunctional data information background management responsive web page template-Novus
backend template
2023-02-02

Real estate resource service platform web page template Bootstrap5

Real estate resource service platform web page template Bootstrap5
Bootstrap template
2023-02-02

Simple resume information web template Bootstrap4

Simple resume information web template Bootstrap4
Bootstrap template
2023-02-02

Cute summer elements vector material (EPS PNG)

This is a cute summer element vector material, including the sun, sun hat, coconut tree, bikini, airplane, watermelon, ice cream, ice cream, cold drink, swimming ring, flip-flops, pineapple, conch, shell, starfish, crab, Lemons, sunscreen, sunglasses, etc., the materials are provided in EPS and PNG formats, including JPG previews.
PNG material
2024-05-09

Four red 2023 graduation badges vector material (AI EPS PNG)

This is a red 2023 graduation badge vector material, four in total, available in AI, EPS and PNG formats, including JPG preview.
PNG material
2024-02-29

Singing bird and cart filled with flowers design spring banner vector material (AI EPS)

This is a spring banner vector material designed with singing birds and a cart full of flowers. It is available in AI and EPS formats, including JPG preview.
banner picture
2024-02-29

Golden graduation cap vector material (EPS PNG)

This is a golden graduation cap vector material, available in EPS and PNG formats, including JPG preview.
PNG material
2024-02-27

Home Decor Cleaning and Repair Service Company Website Template

Home Decoration Cleaning and Maintenance Service Company Website Template is a website template download suitable for promotional websites that provide home decoration, cleaning, maintenance and other service organizations. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-05-09

Fresh color personal resume guide page template

Fresh color matching personal job application resume guide page template is a personal job search resume work display guide page web template download suitable for fresh color matching style. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-29

Designer Creative Job Resume Web Template

Designer Creative Job Resume Web Template is a downloadable web template for personal job resume display suitable for various designer positions. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-28

Modern engineering construction company website template

The modern engineering and construction company website template is a downloadable website template suitable for promotion of the engineering and construction service industry. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-28