Programming Articles

Page 794 of 2547

C# Convert.ToInt32 Method

George John
George John
Updated on 17-Mar-2026 879 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 143 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 589 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 272 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 488 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 589 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

UInt16 Struct in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 619 Views

The UInt16 struct represents a 16-bit unsigned integer. The UInt16 value type represents unsigned integers with values ranging from 0 to 65, 535. The UInt16 struct provides several useful methods for comparison, equality checking, and string conversion operations. Let us explore the key methods with examples. UInt16.CompareTo() Method The UInt16.CompareTo() method compares the current instance to a specified object or UInt16 and returns an indication of their relative values. Syntax Following are the syntax overloads − public int CompareTo(object val); public int CompareTo(ushort val); Parameters val − An ...

Read More

Socket Programming in C#

Samual Sam
Samual Sam
Updated on 17-Mar-2026 2K+ Views

Socket programming in C# enables network communication between applications using the System.Net.Sockets namespace. This namespace provides a managed implementation of the Windows Sockets interface for creating client-server applications that communicate over TCP/IP networks. Socket programming has two basic modes − synchronous (blocking) and asynchronous (non-blocking) operations. Socket Class Constructor Syntax Following is the syntax for creating a Socket instance − Socket socket = new Socket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType); Parameters AddressFamily − Specifies the addressing scheme (InterNetwork for IPv4, InterNetworkV6 for IPv6) SocketType − Defines the type ...

Read More
Showing 7931–7940 of 25,466 articles
« Prev 1 792 793 794 795 796 2547 Next »
Advertisements