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:
-
- 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 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
- 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
- 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()?
- 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?
- 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#?
- 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){  
- C#.Net Tutorial 1064 2023-09-06 14:29:05
-
- 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#?
- 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")){&
- C#.Net Tutorial 1029 2023-09-06 13:33:06
-
- 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{ &
- C#.Net Tutorial 1141 2023-09-06 13:21:07
-
- 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#
- 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
- 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#
- 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#
- 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