current location:Home > Technical Articles > Backend Development > C#.Net Tutorial
- Direction:
- All web3.0 Backend Development Web Front-end Database Operation and Maintenance Development Tools PHP Framework Daily Programming WeChat Applet Common Problem Other Tech CMS Tutorial Java System Tutorial Computer Tutorials Hardware Tutorial Mobile Tutorial Software Tutorial Mobile Game Tutorial
- Classify:
-
- 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#?
- 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?
- 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#
- 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
- 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#?
- 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#?
- 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
- 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
- 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
- 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#
- 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#?
- 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
- 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
- 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#?
- 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