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 use indexers in C# 8.0?
- ^ Operator − It is known as the indexing operator from the end. It returns the index relative to the end of the sequence or collection. Compared to the previous methods, it is the cleanest and easiest way to find the last element. methods.company.listEmployees[^2].Name="Name of employee 2 changed using new syntax";company.listEmployees[^5].Name="Name of employee 5 changed using new syntax";company.listEmployees[^8 ].Name="Employee 8 name changed using new syntax&q
- C#.Net Tutorial 992 2023-09-12 18:53:03
-
- How to list all available files in a directory using C#?
- First, use the DirectoryInfo object -//creatingaDirectoryInfoobjectDirectoryInfomydir=newDirectoryInfo(@"d:\amit"); Now, use the GetFiles() method to get all the files -FileInfo[]f=mydir.GetFiles(); To get the list of files in the directory , please try running the following code - example usingSystem;usingSystem.IO;namespaceDemo{ cla
- C#.Net Tutorial 682 2023-09-12 18:41:08
-
- How to create a directory using C#?
- To create, move and delete directories in C#, the System.IO.Directory class has methods. First, import the System.IO namespace. Now, create the directory in the specified path using Director.CreateDirectory() method - stringmyDir=@"D:\NEW";if(!Directory.Exists(myDir)){ Directory.CreateDirectory(myDir);} Similarly, you can Create a subdirectory −stringmysubdir=@
- C#.Net Tutorial 649 2023-09-12 18:29:08
-
- How to implement the single responsibility principle using C#?
- A class should have only one reason to change. Definition - In this case, responsibility is considered as a reason for change. This principle states that if we have two reasons for changing a class, we must split the functionality into two classes. Each class handles only one responsibility, and if we need to make a change in the future, we will make it in the class that handles it. When we need to make changes to a class that has more responsibilities, that change may affect other functionality related to other responsibilities of that class. Sample Code Before Single Responsibility Principle usingSystem;usingSystem.Net.Mail;namespaceSolidPrinciples.Single.Responsibility
- C#.Net Tutorial 1032 2023-09-12 17:21:02
-
- How to get the current user's desktop path in C#?
- You can use Environment.SpecialFolder to get the current user's desktop path. Environment.SpecialFolder Gets the path to the system special folder identified by the specified enumeration. stringdesktopPath=Environment.GetFolderPath(Environment.SpecialFolder.Desktop) The System.Environment class provides information about the current environment and platform. The System.Environment class is used to retrieve environment variable settings, version of the common language runtime, and call stack
- C#.Net Tutorial 966 2023-09-12 16:49:05
-
- What is the way to sort a list in C#?
- To sort a list in C#, use the Sort() method. Let us first create a list - List<string>myList=newList<string>(); now add elements - myList.Add("Audi");myList.Add("BMW");myList.Add("Chevrolet") ;myList.Add("Hyundai");Use the Sort() method to sort the list -myList.Sort();Example below
- C#.Net Tutorial 1299 2023-09-12 16:13:02
-
- How to create a 6-tuple in C#?
- The Tuple class represents a 6-tuple. A tuple is a data structure with a sequence of elements. It has six properties - Item1 − Gets the value of the first component of the current Tuple object. Item2 − Gets the value of the second component of the current Tuple object. Item3 − Gets the third component of the current Tuple object. Item4 − Gets the fourth component of the current Tuple’s value object. Item5 − Gets the fifth component of the current Tuple object. Item6 − Gets the sixth component of the current Tuple object. Example Now let us see an example of implementing 6-tuple in C# - usingSystem;publicclassDemo{&am
- C#.Net Tutorial 755 2023-09-12 15:53:06
-
- C# program to calculate total number of digits in a number
- Let's assume the number we have is 12. We declared and initialized a uint variable by assigning a decimal literal. uintval=12; The binary representation of 12 is −1100. The number of digits above is 4, so to find the total number of digits, use the Math.log() method −uintres=(uint)Math.Log(val,2.0)+1; Example You can try running the following code to calculate the total number of digits in a number. Live demonstration usingSystem;publicclassDemo{ publicstaticvoid
- C#.Net Tutorial 1163 2023-09-12 15:25:02
-
- C# program to check if there are K consecutive 1's in a binary number
- To check if there are consecutive 1's in a binary number, you need to check 0 and 1. First, set a bool array for 0 and 1 i.e. false and true -bool[]myArr={false,true,false,false,false,true,true,true}; for 0, set the count to 0-if(myArr [i]==false) count=0; For 1, increment the count and set the result. The Max() method returns the larger of the two numbers -count++;res=Math.Max(res,count);Example The following is to check whether there are K consecutive 1's in a binary number
- C#.Net Tutorial 641 2023-09-12 15:21:12
-
- Final local variables in C#
- To make a local variable final, use the read-only keyword in C# because it is not possible to implement the final keyword. The read-only keyword allows a variable to be assigned a value only once. Fields marked "read-only" can only be set once during object construction and cannot be changed. Let's look at an example. Below, we set the empCount field to be read-only and cannot be changed once assigned. Example classDepartment{ readonlyintempCount; Employee(intempCount){ &nb
- C#.Net Tutorial 1449 2023-09-12 15:05:02
-
- How to rotate an array k times using C#?
- Given an array and a number k, the problem states that we need to rotate the array k times. If the given number is 3, the array must be rotated 3 times. Create a function reverse that takes an array, a starting position, and an ending position as parameters. In the first step, the reverse method is called from 0 to the length of the array. In the second step, the reverse method is called from 0 to k-1. In the third step, the reverse method is called from k+1 to the array length. Example Demonstration usingSystem;namespaceConsoleApplication{ publicclassArrays{
- C#.Net Tutorial 551 2023-09-12 14:49:09
-
- What is unboxing in C#?
- Boxing is implicit, unboxing is explicit. Unboxing is the explicit conversion of a reference type created by boxing back to a value type. Let’s see an example of variables and objects in C# −//intintx=30;//Boxingobjectobj=x;//UnboxingintunboxInt=(int)obj;Here is an example that shows Unboxing−intx=5;ArrayListarrList=newArrayList( );//BoxingarrList.Add(x);//UnBoxinginty=(int)arrList[0
- C#.Net Tutorial 906 2023-09-12 13:13:11
-
- What is the usage of DelegatingHandler in Asp.Net webAPI C#?
- In a message handler, a series of message handlers are chained together. The first handler receives the HTTP request, does some processing, and then hands the request to the next handler. At some point, a response is created and returned to the chain. This pattern is called delegate handler. In addition to the built-in server-side message handlers, we can also create our own server-side HTTP message handlers. To create a custom server-side HTTP message handler in ASP.NET Web API, we use DelegatingHandler. We have to create a class derived from System.Net.Http.DelegatingHandler. The custom class should then
- C#.Net Tutorial 656 2023-09-12 11:33:04
-
- C# program to find common elements in three sorted arrays
- First, initialize three sorted arrays - int[]one={20,35,57,70};int[]two={9,35,57,70,92};int[]three={25,35, 55,57,67,70}; To find common elements in a three-sorted array, use a while loop to iterate the array and check the first array using the second array and the second array using the third array - while (i<one.Length&&j<two.Length&&k<three.Length){&n
- C#.Net Tutorial 1227 2023-09-12 11:17:02
-
- .NET performance optimization technology for developers
- If you are a .NET developer, you must be aware of the importance of optimizing functionality and performance in delivering high-quality software. By making expert use of the provided resources and reducing website load times, you not only create a pleasant experience for your users but also reduce infrastructure costs.
- C#.Net Tutorial 941 2023-09-12 10:43:33