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:
-
- Variable parameters (Varargs) in C#
- Use the param keyword in C# to get variable parameters. Let's look at an example of multiplying integers. We use the params keyword to accept any number of int values - staticintMultiply(paramsint[]b) The above code allows us to find the numerical multiplication of one or two int values. The following calls the same function with multiple values - intmulVal1=Multiply(5);intmulVal2=Multiply(5,10); Let us see the complete code to understand how variable parameters work in C# - Example usingSystem;classProgram{ &
- C#.Net Tutorial 1257 2023-09-09 12:57:02
-
- What are recursive method calls in C#?
- Recursive method calls in C# are called recursion. Let's look at an example of calculating powers of numbers using recursion. Here, if the power is not equal to 0, a function call occurs, which ends up being recursive - if(p!=0){ return(n*power(n,p-1));} above, n is the number itself, each iteration When the efficiency is reduced, as shown below - example usingSystem;usingSystem.IO;publicclassDemo{ publicstaticvoidMain(string[]args){ &
- C#.Net Tutorial 1136 2023-09-09 09:13:04
-
- C# program to get and print command line arguments using environment classes
- Introduction Let us see how to write a C# program using C#'s tool environment classes to get and print command line arguments using environment classes. After knowing all about C#, we will now understand one of the uses of system.environment class in C# and then we will learn to write a program that gets and prints command line arguments. Basically it will accept a string as parameter and give its return type as string. Before we dive into the program, we have to understand in detail what environment classes are, so let’s learn about them. What are environment classes in C#? Unless you're learning bootstrap, it's probably very logical to get information about a class by understanding the literal meaning of its name! Because when it comes to boot
- C#.Net Tutorial 813 2023-09-09 08:29:02
-
- What are file operations in C#?
- C# has the following file operations - create, open, read and write files. Add, delete, etc. The FileStream class in the System.IO namespace helps in reading, writing and closing files. This class is derived from the abstract class Stream. You need to create a FileStream object to create a new file or open an existing file. The syntax for creating a FileStream object is as follows -FileStream=newFileStream(<file_name>,<FileModeEnumerator>,<FileAccessEnumerator>,<FileSha
- C#.Net Tutorial 546 2023-09-09 08:01:06
-
- File permissions in C#
- For file permissions in C#, use the FileIOPermission class. It controls the ability to access files and folders. The following are the attributes of the file permission class -Sr.No. method and description 1AllFiles Gets or sets the allowed access permissions for all files. 2AllLocalFiles Gets or sets the allowed access permissions for all local files. The following are the methods of the file permission class - Mr. Number methods and descriptions 1AddPathList(FileIOPermissionAccess,String) This method adds access permissions to the specified file or directory to the existing state of the permissions 2Copy() This method creates and returns a copy of the same current permissions . 3Get
- C#.Net Tutorial 1069 2023-09-08 21:29:02
-
- What is the difference between Monitor and Lock in C#?
- Both monitors and locks provide mechanisms for synchronizing object access. lock is a shortcut for Monitor.Enter and try and finally. Lock is a shortcut and an option for basic usage. If we need more control to implement an advanced multi-threading solution using TryEnter(), Wait(), Pulse() and & PulseAll() method, then the Montior class is your choice. Lock Example - Example classProgram{staticobject_lock=newobject();staticintTotal;publicstaticvoidMain(
- C#.Net Tutorial 739 2023-09-08 21:13:07
-
- How to convert C# DateTime to 'YYYYMMDDHHMMSS' format?
- Convert datetime to toString, thus converting datetime to "YYYYMMDDHHMMSS" format Datetime can also convert other formats MM/dd/yyyy08/22/2020dddd, ddMMMMyyyy Tuesday, August 22, 2020 dddd, ddMMMMyyyyHH:mm August 2020 Tuesday 22nd August 06:30dddd,ddMMMMyyyyhh:mmttTuesday 22nd August 2020 06:30AMdddd,ddMMMMyyyyH:mm Tuesday 22nd August 2020 6:30dddd,ddMMMyyyyh:mmtt2020
- C#.Net Tutorial 1397 2023-09-08 21:05:02
-
- C# program to find maximum number in array using WHERE clause LINQ
- Introduction In this article, we will find the maximum number in an array using WHERE clause in LINQ. LINQ (Language Integrated Query) is used to generate queries in C# language. The best part of LINQ is that it provides a unified source of methods to access data from different sources such as databases and XML documents. With LINQ, users can write more readable code, and the code is more concise and beautiful. It also provides other features such as filtering, sorting, grouping data, and even changing data. Before we continue, we will learn about Language Integrated Query (aka LINQ) in detail, we will also look at the different clauses under LINQ and namespaces, especially the clauses that we will use in our code. Language integrated query LINQ is .NE
- C#.Net Tutorial 1238 2023-09-08 19:25:06
-
- How to restrict Parallel.ForEach in C#?
- Parallel.ForEach loop in ParallelForeachC# runs on multiple threads and processing happens in parallel. Parallel.ForEach loops are not a basic feature of C# and are available starting with C# 4.0 and above. To use Parallel.ForEach loop, we need to import System.Threading.Tasks namespace in using directive. Foreach loop in ForeachC# runs on a single thread and processing happens one by one in sequence. Foreach loop is a basic function of C#, available since C# 1.0. In most cases, its execution speed
- C#.Net Tutorial 690 2023-09-08 19:09:07
-
- C# program to copy existing files
- Use the File.Copy method to copy an existing file. Add the path to the file to be copied. StringmyPath=@"D:\one.txt";Now copy the above file to the following file −StringmyPath=@"D:\one.txt";Use the File.Copy method, specifying both the source file and the target file. File.Copy(myPath,newpath);Example usingSystem;usingSystem.IO;publicclassProgram{ &nb
- C#.Net Tutorial 1956 2023-09-08 18:21:16
-
- What are collection classes in C#?
- Collection classes serve various purposes such as dynamically allocating memory to elements, accessing a list of items based on index, etc. The following are the classes in Collections: Ordinal Category and Description and Usage 1ArrayList It represents an ordered collection of objects that can be individually indexed. 2Hashtable It uses keys to access elements in the collection. 3SortedList It uses keys and indexes to access items in the list. 4Stack represents a last-in-first-out collection of objects. 5Queue represents a first-in, first-out collection of objects. 6BitArray It represents an array using binary representation of values 1 and 0. Let's look at an example of the BitArray class in C#: Example Online
- C#.Net Tutorial 1166 2023-09-08 17:25:02
-
- How to iterate over any Map in C#
- C# has no built-in math types. Again, use a dictionary. First, create a dictionary-Dictionary<string,int>d=newDictionary<string,int>();d.Add("keyboard",1);d.Add("mouse",2); get the key-varval= d.Keys.ToList(); Now, use foreach loop to iterate Map-foreach(varkeyinval){ Console.Wr
- C#.Net Tutorial 1889 2023-09-08 16:57:02
-
- Inheritance and composition in C#
- Inheritance allows you to specify that a new class should inherit members of an existing class. This existing class is called the base class and the new class is called the derived class. Inheritance implements the IS-A relationship. For example, a mammal is an animal, a dog is a mammal, therefore a dog is an animal, and so on. For example, the base class Shape has derived classes such as Circle, Square, Rectangle, etc. Under the composition, if the parent object is deleted, the child object will also lose its state. A combination is a special type of aggregation and gives partial relationships. For example, a car has an engine. If the car is destroyed, the engine will be destroyed as well. Example publicclassEngine{ &nb
- C#.Net Tutorial 1362 2023-09-08 16:21:04
-
- Boxing and unboxing in C#
- Boxing Boxing is the implicit conversion of a value type to a reference type. Unboxing Unboxing is the explicit conversion of a reference type created by boxing back to a value type. Example Let’s see an example code snippet – //intintmyVal=12; //BoxingobjectmyBoxed=myVal; //UnboxingintmyUnBoxed=(int)myBoxed; Let’s see another example of displaying an array list in C# – inta=5;ArrayListarr= newArrayList();//Boxingarr.Add(a);//UnBoxingintb=(int)arr[0];
- C#.Net Tutorial 1191 2023-09-08 14:57:11
-
- How to get file size in C#?
- FileInfo class is used to handle files and their operations in C#. It provides properties and methods for creating, deleting, and reading files. It uses the StreamWriter class to write data to a file. It is part of the System.IO namespace. The Directory property retrieves an object representing the file's parent directory. The DirectoryName property retrieves the full path of the parent directory. The Exists property checks whether a file exists before operating on it. The IsReadOnly property retrieves or sets a value that specifies whether the file can be read. Revise. Length retrieves the size of the file. Name retrieves the name of the file. Example classProgram{&nb
- C#.Net Tutorial 1937 2023-09-08 14:29:02