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

  • Swap characters of string in C#
    Swap characters of string in C#
    To swap characters of a string, use the Select method. First, let's say our string is - stringstr="PQRQP"; now you need to swap every occurrence of P with Q and Q with P - str.Select(a=>a=='P'?' Q':(a=='Q'?'P':a)).ToArray();The characters are replaced above. Let's look at the complete code - Example Live Demonstration usingSystem;usingS
    C#.Net Tutorial 1085 2023-09-06 18:01:06
  • String literals vs. string objects in C#
    String literals vs. string objects in C#
    String literals String literals or constants are enclosed in double quotes "" or @"". Strings contain characters similar to character literals: plain characters, escape sequences, and universal characters. Here are some examples of string literals-Hello,World""Welcome,\The following are examples of showing string literal usage-Example usingSystem;namespaceDemo{ classProgram{ staticvoidMain(string[]args){ &
    C#.Net Tutorial 950 2023-09-06 17:45:07
  • C# program counts the number of occurrences of each character
    C# program counts the number of occurrences of each character
    First, set the string - stringstr="Website";Console.WriteLine("String:"+str); Check each character in the string and add a variable to count the number of times that character appears -for(intj=0; j<str.Length;j++){ if(str[0]==str[j]){ cal++; }}ExampleYou can
    C#.Net Tutorial 1896 2023-09-06 17:41:02
  • How to use both Take and Skip operators in LINQ C# programming
    How to use both Take and Skip operators in LINQ C# programming
    We are creating two instances of Employee class, e and e1. e is assigned to e1. Both objects point to the same reference, so we will get true for all Equals, as expected output. In the second case, we can observe that Equals returns false despite the same property values. Basically, equals does not check the value and always returns false when the parameters refer to different objects. Example 1classProgram{ staticvoidMain(string[]args){ Employeee=n
    C#.Net Tutorial 853 2023-09-06 16:45:07
  • What is the C# equivalent of Java's isInstance()?
    What is the C# equivalent of Java's isInstance()?
    java.lang.Class.isInstance() determines whether the specified Object is compatible with assignment to the object represented by the class. Java's isInstance() method is equivalent to IsAssignableFrom() in C#. Another simplest method equivalent to isInstance() is - boolres=(obisDemoClass); You can also use Type.IsInstanceOfType to get the same result - ob.GetType().IsInstanceOfType(otherOb)
    C#.Net Tutorial 1157 2023-09-06 16:33:04
  • What is the difference between IApplicationBuilder.Use() and IApplicationBuilder.Run() C# Asp.net Core?
    What is the difference between IApplicationBuilder.Use() and IApplicationBuilder.Run() C# Asp.net Core?
    We can configure the middleware in the Configure method of the Startup class, using an IApplicationBuilder instance. Run() is an extension method on an IApplicationBuilder instance that adds a terminal to add middleware to the application's request pipeline. The Run method is an extension method of IApplicationBuilder and accepts a RequestDelegate parameter. Signature of Run method publicstaticvoidRun(thisIApplicationBuilderapp,RequestDelegatehandler)R
    C#.Net Tutorial 780 2023-09-06 16:01:09
  • How to access elements in multidimensional array in C#?
    How to access elements in multidimensional array in C#?
    To access an element in a multidimensional array just add the index of the desired element e.g. - a[2,1] Above access the element from row 3 column 2 i.e. element 3 as shown below in out[3,4] In Arrays - 00122436 Let's see what we discussed and access elements in a 2D array - Example usingSystem;namespaceProgram{ classDemo{ staticvoidMain(string[]args){ &nbsp
    C#.Net Tutorial 1064 2023-09-06 14:29:05
  • The difference between hash table and dictionary in C#
    The difference between hash table and dictionary in C#
    Hash tables and dictionaries are both types of data structures used to store data. Both data structures store data in the form of key-value pairs. Based on the differences between their key characteristics, we can differentiate between HashTable and Dictionary as follows - Sr. Number Key Hash Table Dictionary 1 Dictionary 1 Definition HashTable is a non-generic collection used to store data in the form of key/value pairs, Definition In the System.Collections namespace. Dictionary, on the other hand, is a collection of generic types defined under the System.Collection.Generics namespace, which also stores data in the form of key/value pairs. 2DataType in HashT
    C#.Net Tutorial 1054 2023-09-06 13:49:02
  • How to open hidden files using C#?
    How to open hidden files using C#?
    To open a hidden file, first make it visible. You can do this by removing the hidden attributes set on it - FileInfofile=newFileInfo(Environment.CurrentDirectory+@"\myFile.txt");file.Attributes&=~FileAttributes.Hidden; Now treat it as a normal text file and Open it. Read content-using(StreamReadersr=newStreamReader("myFile.txt")){&amp
    C#.Net Tutorial 1029 2023-09-06 13:33:06
  • C# program to count the number of occurrences of a word in a string
    C# program to count the number of occurrences of a word in a string
    First set the string - stringstr="HelloWorld!Hello!"; now check if the word "Hello" appears in the string and loop -while((a=str1.IndexOf(pattern,a))!=-1){ a+= pattern.Length; count++;} Example You can try running the following code to count the number of occurrences of a word in a string. Real-time demonstration usingSystem;classProgram{ &amp
    C#.Net Tutorial 1141 2023-09-06 13:21:07
  • C# program to merge two hash table collections
    C# program to merge two hash table collections
    Hash table collections in C# store key-value pairs. Each element or item in the collection is a key-value pair, that is, the collection is a two-element collection. Key is unique, non-empty, and is used to access elements in the hash table. Hash table collections are immutable and cannot have duplicate elements. This means that key-value combinations should be unique. However, these values ​​can be empty or repeated. .NetFramework provides a HashTable class to implement a collection of hash tables and contains the functionality required to implement a hash table without any additional coding. Each element in the hash table collection is a DictionaryEntry object with two properties: a key element and a value element. When an element is added to the hash table, the hash is automatically generated
    C#.Net Tutorial 716 2023-09-06 11:21:08
  • Find available disk space using C#
    Find available disk space using C#
    First, create an instance of DriveInfo - DriveInfodInfo=newDriveInfo("E"); Display the available space - Console.WriteLine("DiskFreespace={0}",dInfo.AvailableFreeSpace); Now, use the AvailableFreeSpace property and get the percentage of available space - Doublepc =(dInfo.AvailableFreeSpace/(float)dInfo.TotalSize)*100;Here, you will get
    C#.Net Tutorial 977 2023-09-06 10:29:02
  • C# truncation method
    C# truncation method
    Use the Truncate method in C# to remove all digits after the decimal point. Assume below is our number - 20.35M To remove the digits after the decimal point use Truncate() - decimal.Truncate(20.35M) Let’s see the complete code - Example usingSystem;usingSystem.Linq;classDemo{ staticvoidMain(){ decimaldc=20.35M;
    C#.Net Tutorial 1222 2023-09-06 09:29:06
  • Basic calculator program using C#
    Basic calculator program using C#
    To create a calculator program using C#, you need to use Web Forms. Create buttons for 1-9, addition, subtraction, multiplication, etc. under it. Let's look at the codes for addition, subtraction and multiplication. First, we declared two variables - staticfloatx,y; now, we will see how to set up the calculation code on a single button click: Our result text box is a tbResult, because we also use Windows Forms to display the calculator - protectedvoidadd_Click (objectsender,EventArgse){ x=Convert.ToInt32(tbResult
    C#.Net Tutorial 841 2023-09-06 08:45:13
  • Overloaded methods and ambiguity in C#
    Overloaded methods and ambiguity in C#
    Method overloading allows you to have multiple definitions of the same function name in the same scope. Function definitions must differ in the type and/or number of parameters in the parameter list. Let's look at an example. Here, the call goes to a method with a single parameter - example usingSystem;classStudent{ staticvoidDisplayMarks(intmarks1=90){ Console.WriteLine("Methodwithoneparameter!&q
    C#.Net Tutorial 758 2023-09-06 08:45:10

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