Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Programming Articles
Page 795 of 2547
Buffer Type in C#
The Buffer class in C# provides efficient methods for manipulating arrays of primitive types at the byte level. It is particularly useful when you need to perform fast operations on large arrays or when working with binary data. The Buffer.BlockCopy method is the most commonly used method, which copies bytes from one array to another. Syntax Following is the syntax for the Buffer.BlockCopy method − Buffer.BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count); Parameters src − The source array from which bytes are copied srcOffset − The byte offset into ...
Read MoreLinkedList AddAfter method in C#
The AddAfter method in C# LinkedList allows you to insert a new node immediately after a specified existing node. This method provides precise control over node placement within the linked list structure. Syntax The AddAfter method has two overloads − public LinkedListNode AddAfter(LinkedListNode node, T value) public void AddAfter(LinkedListNode node, LinkedListNode newNode) Parameters node: The existing node after which the new node will be inserted value: The value to be stored in the new node (first overload) newNode: An existing node to be inserted ...
Read MoreHow to Initialize and Compare Strings in C#?
String initialization and comparison are fundamental operations in C# programming. C# provides multiple ways to initialize strings and several methods to compare them effectively. String Initialization There are several ways to initialize a string in C# − // Direct assignment string str1 = "Hello, World!"; // Using string constructor string str2 = new string("Welcome"); // Empty string initialization string str3 = ""; string str4 = string.Empty; Example using System; class Program { static void Main(string[] args) { ...
Read MoreSelection Sort program in C#
Selection Sort is a sorting algorithm that finds the minimum value in the array for each iteration of the loop. Then this minimum value is swapped with the current array element. This procedure is followed until the array is sorted in ascending order. The algorithm divides the array into two parts: a sorted portion (initially empty) and an unsorted portion (initially the entire array). In each iteration, it selects the smallest element from the unsorted portion and moves it to the end of the sorted portion. How Selection Sort Works Selection Sort Process ...
Read MoreUInt32 Struct in C#
The UInt32 struct represents a 32-bit unsigned integer in C#. The UInt32 value type represents unsigned integers with values ranging from 0 to 4, 294, 967, 295 (2³² - 1). This struct provides several useful methods for comparison, equality checking, and value manipulation. Let us explore the key methods with practical examples. Syntax Following is the syntax for declaring a UInt32 variable − uint variableName = value; UInt32 variableName = value; The uint keyword is an alias for UInt32 and both can be used interchangeably. UInt32 Value Range ...
Read MoreWhat are control statements in C#?
Control statements in C# determine the flow of program execution by specifying which code blocks to execute based on conditions or how many times to repeat certain operations. These statements are fundamental building blocks that allow developers to create dynamic and responsive applications. C# provides several types of control statements that can be categorized into conditional statements (if, if-else, switch) and loop statements (for, while, do-while, foreach). Let's explore the main control statements with practical examples. if Statement An if statement executes a block of code only when a specified boolean condition evaluates to true. Syntax ...
Read MoreString format for DateTime in C#
The String.Format method in C# provides powerful formatting capabilities for DateTime objects. You can use various format specifiers to display dates and times in different formats, from simple year displays to complex custom patterns. Syntax Following is the syntax for formatting DateTime using String.Format − String.Format("{0:format_specifier}", dateTimeObject) Common format specifiers include − y − Year (1 digit minimum) yy − Year (2 digits) yyyy − Year (4 digits) M − Month (1-12) MM − Month (01-12) MMM − Month abbreviation (Jan, Feb, etc.) MMMM − Full month name (January, February, etc.) d ...
Read MoreThread Synchronization in C#
Thread synchronization in C# is essential for coordinating access to shared resources in multithreaded applications. It prevents race conditions and ensures data consistency by controlling how multiple threads access critical sections of code. C# provides several synchronization mechanisms including the lock statement, Mutex class, and other primitives to manage concurrent thread execution effectively. Syntax Following is the syntax for using the lock statement − lock (syncObject) { // critical section code } Following is the syntax for creating and using a Mutex − private static Mutex mutex ...
Read MoreChar.IsSymbol() Method in C#
The Char.IsSymbol() method in C# determines whether a specified character is categorized as a symbol character. Symbol characters include mathematical symbols, currency symbols, and other non-alphanumeric characters that are not punctuation or control characters. Syntax The method has two overloads − public static bool IsSymbol(char c); public static bool IsSymbol(string str, int index); Parameters c − The Unicode character to evaluate. str − A string containing the character to evaluate. index − The position of the character to evaluate in the string. Return Value Returns true if the character ...
Read MoreDateTime.FromOADate() Method in C#
The DateTime.FromOADate() method in C# converts an OLE Automation Date value into a DateTime object. OLE Automation Date is a floating-point representation of dates and times where the integer part represents the number of days since December 30, 1899, and the fractional part represents the time of day. Syntax Following is the syntax for the DateTime.FromOADate() method − public static DateTime FromOADate(double d); Parameters The method takes a single parameter − d: A double-precision floating-point number representing the OLE Automation Date value. It can range from -657435.0 to 2958465.99999999. ...
Read More