Articles on Trending Technologies

Technical articles with clear explanations and examples

Singleton Class in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 3K+ Views

A Singleton class in C# is a design pattern that ensures only one instance of a class can be created throughout the application's lifetime. It provides a global point of access to that instance and is commonly used for logging, database connections, and configuration management. The key principle of the Singleton pattern is to restrict instantiation of a class to a single object by using a private constructor and providing a static method or property to access the instance. Syntax Following is the basic syntax for implementing a Singleton class − public class Singleton { ...

Read More

Combine two arrays in C#

George John
George John
Updated on 17-Mar-2026 6K+ Views

Combining two arrays in C# can be accomplished using various methods. The most common approaches include using List.AddRange() method, Array.Copy(), or LINQ's Concat() method. Syntax Using List.AddRange() method − var list = new List(); list.AddRange(array1); list.AddRange(array2); T[] combinedArray = list.ToArray(); Using Array.Copy() method − T[] combinedArray = new T[array1.Length + array2.Length]; Array.Copy(array1, 0, combinedArray, 0, array1.Length); Array.Copy(array2, 0, combinedArray, array1.Length, array2.Length); Using LINQ Concat() method − T[] combinedArray = array1.Concat(array2).ToArray(); Using List.AddRange() Method This approach creates a List, adds both arrays using AddRange(), then converts ...

Read More

C# Convert.ToInt32 Method

George John
George John
Updated on 17-Mar-2026 891 Views

The Convert.ToInt32 method in C# is used to convert various data types to a 32-bit signed integer. It is commonly used to convert strings, floating-point numbers, and other numeric types to integers, providing a versatile approach to type conversion. Syntax Following are the most common syntax forms for Convert.ToInt32 − Convert.ToInt32(value); Convert.ToInt32(value, fromBase); Parameters value − The value to convert (string, double, decimal, bool, etc.) fromBase − Optional. The base of the number system (2, 8, 10, or 16) Return Value Returns a 32-bit signed integer equivalent to the ...

Read More

What is the Length property of BitArray class in C#?

Samual Sam
Samual Sam
Updated on 17-Mar-2026 146 Views

The Length property of the BitArray class in C# is used to get or set the number of elements in the BitArray. This property allows you to determine the size of the bit array and also resize it when needed. Syntax Following is the syntax for using the Length property − public int Length { get; set; } Return Value The Length property returns an int value representing the number of elements in the BitArray. Using Length Property to Get BitArray Size You can use the Length property to determine how ...

Read More

Math Class in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 2K+ Views

The Math class in C# provides static methods and constants for trigonometric, logarithmic, and other mathematical functions. This class is part of the System namespace and offers essential mathematical operations without requiring instantiation. The Math class includes important mathematical constants like Math.E and Math.PI, along with numerous methods for calculations such as power, trigonometric, and logarithmic functions. Math Constants Math.E The Math.E field represents the natural logarithmic base, specified by the mathematical constant e − public const double E = 2.71828182845905; using System; public class Demo { ...

Read More

How to concatenate Two Arrays in C#?

Samual Sam
Samual Sam
Updated on 17-Mar-2026 596 Views

To concatenate two arrays in C#, you can use several methods depending on your requirements. The most common approaches include using the Concat() method from LINQ, copying elements manually, or using Array.Copy(). Syntax Using LINQ Concat() method − var result = array1.Concat(array2).ToArray(); Using Array.Copy() method − Array.Copy(sourceArray, destinationArray, length); Using LINQ Concat() Method The Concat() method from LINQ is the most straightforward way to concatenate arrays. It creates a new array containing elements from both arrays − using System; using System.Linq; class Program { ...

Read More

What are circular references in C#?

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 4K+ Views

A circular reference in C# occurs when two or more objects reference each other directly or indirectly, creating a dependency loop. This can cause memory leaks and prevent proper garbage collection if not handled correctly. The .NET garbage collector is designed to detect and handle circular references automatically. It uses a mark-and-sweep algorithm that starts from root objects (like static variables and local variables) and marks all reachable objects, then collects unmarked objects even if they have circular references. Understanding Circular References Circular references typically occur in parent-child relationships, linked lists, or complex object graphs where objects ...

Read More

Singly LinkedList Traversal using C#

George John
George John
Updated on 17-Mar-2026 277 Views

A LinkedList in C# is a doubly-linked list that allows efficient insertion and removal of elements. Traversal refers to visiting each node in the LinkedList sequentially to access or process the data. The LinkedList class in C# provides various methods to traverse through its elements, with the most common approach being the foreach loop. Syntax Following is the syntax for declaring a LinkedList − var linkedList = new LinkedList(); Following is the syntax for traversing a LinkedList using foreach − foreach(var item in linkedList) { // Process each ...

Read More

Implicit conversion from UInt64 to Decimal in C#

Samual Sam
Samual Sam
Updated on 17-Mar-2026 490 Views

The ulong type represents a 64-bit unsigned integer (UInt64) that can store values from 0 to 18, 446, 744, 073, 709, 551, 615. C# supports implicit conversion from ulong to decimal, meaning the conversion happens automatically without requiring explicit casting. This conversion is safe because the decimal type can represent all possible ulong values without data loss, though the internal representation changes from integer to floating-point decimal format. Syntax Following is the syntax for implicit conversion from ulong to decimal − ulong ulongValue = value; decimal decimalValue = ulongValue; // implicit conversion ...

Read More

Char.IsControl(String, Int32) Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 595 Views

The Char.IsControl(String, Int32) method in C# determines whether the character at a specified position in a string is a control character. Control characters are non-printable characters used for formatting and text control, such as tab (\t), newline (), and carriage return (\r). Syntax Following is the syntax for the Char.IsControl(String, Int32) method − public static bool IsControl(string str, int index); Parameters str − The string to examine. index − The zero-based position of the character to evaluate in the string. Return Value Returns true if ...

Read More
Showing 10601–10610 of 61,297 articles
Advertisements