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

  • How to use indexers in C# 8.0?
    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#?
    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#?
    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#?
    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#?
    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#?
    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#?
    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
    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
    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#
    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#?
    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#?
    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#?
    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
    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
    .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

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