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 get all files, subfiles and their sizes in a directory in C#?
- To get files, C# provides a method Directory.GetFilesDirectory.GetFiles returns the names of all files (including their paths) matching the specified search pattern, and optionally searches subdirectories. In the following example, * matches zero or more characters in that position. SearchOptionTopDirectoryOnly. Search only top-level directories SearchOptionAllDirectories. Search all top-level directories and subdirectories FileInfo to obtain file length, name and other information Example 1staticvoidMain(string[]args){&nbs
- C#.Net Tutorial 1623 2023-09-16 12:49:02
-
- Priority Queue in C#
- A priority queue is a message with a priority value. It is an extension of the queue. When you try to remove an item from the priority queue, the item with the highest attribute is removed first. Let's see how to set up a priority queue − publicclassMyPriorityQueue<T>whereT:IComparable<T>{} Now let's add an item. In the example below, the items are stored in info, which is a generic list. Example publicclassMyPriorityQueue<T>whereT:IComparable<T>{&
- C#.Net Tutorial 1523 2023-09-16 11:05:02
-
- What different types of conditional statements does C# support?
- A conditional statement requires the programmer to specify one or more conditions to be evaluated or tested by the program, and one or more statements to be executed when the condition is determined to be true, and optionally, additional statements to be executed when the condition is determined to be false. The following are the types of conditional statements: Ordinal statement and description 1 if statement The if statement consists of a Boolean expression followed by one or more statements. 2if...else statement The if statement can be followed by an optional else statement, which is executed when the Boolean expression is false. 3Nested if statements You can use an if or elseif statement inside another if or elseif statement. 4switch statement The switch statement allows variables to be tested for equality and compared with a range of values.
- C#.Net Tutorial 644 2023-09-16 08:49:02
-
- BitArray class in C#
- The BitArray class manages a compact array of bit values represented as Boolean values, where true means the bit is on (1) and false means the bit is off (0). The following table lists some common methods of the BitArray class - Sr.No. method and description 1 publicBitArrayAnd(BitArrayvalue); performs a bitwise AND operation between the elements in the current BitArray and the corresponding elements in the specified BitArray. 2publicboolGet(intindex); Get the value of the bit at a specific position in BitArray. 3publicBitArrayNot();Reverse the current BitArray
- C#.Net Tutorial 1533 2023-09-16 08:05:02
-
- C# program showing usage of LINQ Aggregate() method
- The Aggregate() method is a powerful LINQ method that allows you to perform reduction operations on a sequence of elements. This method can be used to perform calculations on a set of data, such as finding the sum, product, or maximum of a set of numbers. In this article, we will explore how to use Aggregate() method in C# programs. What is the Aggregate() method? The Aggregate() method is a LINQ extension method that takes two parameters: a seed value and a function that performs a reduction operation on the sequence of elements. The seed value is the initial value for the operation, and the function specifies how to combine each element in the sequence with the previous result. Syntax of Aggregate() method publicstaticTAccu
- C#.Net Tutorial 839 2023-09-15 23:25:06
-
- Numbers in C#
- For numbers in C#, use int type. It represents an integer, which can be positive or negative. Let’s see how to add two integers using mathematical operator +- in C# usingSystem;usingSystem.Linq;classProgram{ staticvoidMain(){ intx=20; inty=30; i
- C#.Net Tutorial 1352 2023-09-15 23:13:02
-
- How to use C# FileStream class?
- The FileStream class provides streams for file operations such as reading and writing. Create an object like this FileStreamfstream=newFileStream("d:\ew.txt",FileMode.OpenOrCreate); Above we used FileMode.OpenOrCreate to open or create the file (if the file does not exist yet). The following example shows how to use the FileStream class in C# - usingSystem;usingSystem.IO;publicclassDemo{ &
- C#.Net Tutorial 673 2023-09-15 22:41:06
-
- A brief overview of the C# and .NET ecosystem
- C# is an object-oriented, type-safe, general-purpose programming language that focuses on improving programmer productivity. It attempts to achieve this productivity through expressiveness, simplicity, and a focus on performance. It is available on different platforms such as Windows, Mac, and Linux. Type Safety C# is a statically typed language. This means that types are verified when the program is compiled. This can eliminate a large number of errors before the program is run. Garbage collection and automatic memory management are a fundamental feature of C#. It has a garbage collector that runs alongside the program to reclaim unused memory. This relieves the programmer from the burden of explicitly freeing memory. The .NET ecosystem supports C# programs through the common language runtime and base class libraries. It also includes an app
- C#.Net Tutorial 1078 2023-09-15 22:17:06
-
- Time functions in C#
- DateTime has methods and properties for date and time, as well as how to get the hours or minutes of a day, etc. Let's just focus on the time functions - see MSDN (Microsoft Developer Network) for all functions - Sr.No. Methods and Properties 1AddDays(Double) Returns a new DateTime that adds the specified number of days to the value of this instance. 2AddHours(Double) Returns a new DateTime that adds the specified number of hours to this instance's value. 3AddMilliseconds(Double) returns the new DateTime milliseconds that add the specified number to the value of this instance
- C#.Net Tutorial 727 2023-09-15 21:37:02
-
- How to get thread ID from thread in C#?
- A thread is defined as the execution path of a program. Each thread defines a unique flow control. If your application involves complex and time-consuming operations, it is often helpful to set up different execution paths or threads, each thread performing a specific task. Threads are lightweight processes. A common example of the use of threads is in modern operating systems to implement concurrent programming. Using threads saves wasted CPU cycles and increases the efficiency of your application. In C#, the System.Threading.Thread class is used to handle threads. It allows the creation and access of individual threads in multi-threaded applications. In a process, the first thread to execute is called the main thread. When a C# program starts executing, the main thread will automatically create
- C#.Net Tutorial 1606 2023-09-15 20:25:02
-
- C# string properties
- The following are the properties of the String class in C# -Sr.No property & description 1Chars Gets the Char object at the specified position in the current String object. 2Length gets the number of characters in the current String object. Example Let's look at an example - live demonstration usingSystem;publicclassDemo{ publicstaticvoidMain(){ stringstr1="h8b9"; &nbs
- C#.Net Tutorial 858 2023-09-15 19:25:02
-
- How to get Unix timestamp in C#
- Unix timestamps are mainly used in Unix operating systems. But it is helpful for everyone operating the system because it represents the time in all time zones. Unix timestamp represents time in seconds. The Unix epoch begins on January 1, 1970. Therefore, a Unix timestamp is the number of seconds between a specific date. Example Use DateTime.Now.Subtract to get the Unix timestamp(). Total seconds method classProgram{ staticvoidMain(string[]args){ Int32unixTime
- C#.Net Tutorial 836 2023-09-15 18:49:02
-
- How to define custom method in C#?
- To define a custom method in C#, use the following syntax −<AccessSpecifier><ReturnType><MethodName>(ParameterList){MethodBody}The followingarethevariouselementsofamethod−AccessSpecifier−Thisdeterminesthevisibilityofava
- C#.Net Tutorial 1043 2023-09-15 18:17:06
-
- Bitwise right shift operator in C#
- Bitwise operators act on bits and perform bitwise operations. In the bitwise right shift operator, the value of the left operand is shifted to the right by the number of bits specified by the right operand. In the code below we have the value -60i.e.00111100 shifted right by %minus;c=a>>2; after shifted right twice it converts to 15-15i.e.00001111 Example you can try to run the following code to achieve Bitwise right shift operator in C#-usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceDemo{ classto
- C#.Net Tutorial 1229 2023-09-15 18:13:02
-
- Explain the difference between const and readonly keywords in C#
- In C#, both the const and readonly keywords are used to define immutable values, which cannot be modified once declared. However, there are some important differences between the two. The constconst modifier declares constant values that are known at compile time and will not change, i.e. they are immutable. In C#, only built-in types can be marked const. User-defined types (such as classes, structures, etc.) cannot be const. Additionally, class member types (such as methods, properties, or events) cannot be marked as constants. You must initialize constants during declaration. classPeriod{ publicconsstinthours=12;&
- C#.Net Tutorial 1084 2023-09-15 16:33:02