Csharp Articles

Page 18 of 196

Stack.CopyTo() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 155 Views

The Stack.CopyTo() method in C# is used to copy all elements of a Stack to an existing one-dimensional Array, starting at a specified array index. This method is useful when you need to transfer stack data into an array for further processing or storage. Syntax Following is the syntax of the Stack.CopyTo() method − public virtual void CopyTo(Array arr, int index); Parameters arr − The one-dimensional Array that is the destination of the elements copied from Stack. The Array must have zero-based indexing. index − The zero-based index in ...

Read More

Queue.ToArray Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 167 Views

The Queue.ToArray() method in C# copies all Queue elements to a new array. This method creates a shallow copy of the queue's elements in the same order (FIFO - First In, First Out). Syntax The syntax for the generic Queue is as follows − public T[] ToArray(); Return Value Returns a new array of type T[] containing copies of the elements from the Queue. The array elements maintain the same order as they would be dequeued from the queue. Queue.ToArray() Process Queue ...

Read More

SortedDictionary.Count Property in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 173 Views

The SortedDictionary.Count property in C# returns the number of key/value pairs contained in the SortedDictionary. This read-only property is useful for determining the size of the collection and checking if it's empty. Syntax Following is the syntax for the Count property − public int Count { get; } Return Value The Count property returns an int value representing the total number of key/value pairs in the SortedDictionary. It returns 0 if the dictionary is empty. SortedDictionary Count Property Key-Value Pairs: {100: ...

Read More

SortedDictionary.Item[] Property in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 160 Views

The SortedDictionary.Item[] property in C# provides indexer access to get or set values associated with specified keys in a sorted dictionary. This property allows you to access dictionary elements using square bracket notation, making it convenient to retrieve and modify values. Syntax Following is the syntax for the SortedDictionary.Item[] property − public TValue this[TKey key] { get; set; } Parameters key − The key of the value to get or set of type TKey. Return Value Returns the value of type TValue associated with the specified key. ...

Read More

Single.ToString Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 163 Views

The Single.ToString() method in C# converts a float (single-precision floating-point) value to its string representation. This method is essential for displaying numeric values as text or preparing them for output operations. Syntax Following is the syntax for the parameterless ToString() method − public override string ToString(); The method can also accept format parameters − public string ToString(string format); public string ToString(IFormatProvider provider); public string ToString(string format, IFormatProvider provider); Return Value The method returns a string representation of the float value. Special values like infinity and NaN have specific string ...

Read More

BitConverter.ToInt16() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 342 Views

The BitConverter.ToInt16() method in C# is used to convert two consecutive bytes from a byte array into a 16-bit signed integer (short). This method reads bytes in little-endian format, where the first byte represents the lower-order bits and the second byte represents the higher-order bits. Syntax Following is the syntax for the BitConverter.ToInt16() method − public static short ToInt16(byte[] value, int startIndex); Parameters value − The byte array containing the bytes to convert. startIndex − The starting position within the byte array from which to begin reading two bytes. Return ...

Read More

BitConverter.ToDouble() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 317 Views

The BitConverter.ToDouble() method in C# is used to return a double-precision floating-point number converted from eight bytes at a specified position in a byte array. This method interprets 8 consecutive bytes as a 64-bit IEEE 754 floating-point number. Syntax The syntax is as follows − public static double ToDouble(byte[] value, int startIndex); Parameters value − An array of bytes containing the 8 bytes to convert. startIndex − The starting position within the byte array from which to begin reading the 8 bytes. Return Value Returns ...

Read More

Single.CompareTo() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 272 Views

The Single.CompareTo() method in C# is used to compare a float value with another float or object and returns an integer indicating the relative order. This method is essential for sorting operations and determining numerical relationships between single-precision floating-point numbers. Syntax The Single.CompareTo() method has two overloads − public int CompareTo(float value); public int CompareTo(object value); Parameters value − A float number or an object to compare with the current instance. Return Value The method returns an int value indicating the comparison result − ...

Read More

BitConverter.ToInt32() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 489 Views

The BitConverter.ToInt32() method in C# is used to convert four bytes from a byte array at a specified position into a 32-bit signed integer. This method reads four consecutive bytes and interprets them as an integer value according to the system's endianness (little-endian on most systems). Syntax Following is the syntax for the BitConverter.ToInt32() method − public static int ToInt32(byte[] value, int startIndex); Parameters value − A byte array containing the bytes to convert. startIndex − The starting position within the value array (zero-based index). Return Value Returns a ...

Read More

SByte.ToString() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 484 Views

The SByte.ToString() method in C# is used to convert the numeric value of a signed byte to its equivalent string representation. The sbyte data type represents 8-bit signed integers with values ranging from -128 to 127. Syntax Following is the syntax for the basic ToString() method − public override string ToString(); Following is the syntax for ToString() with format provider − public string ToString(IFormatProvider provider); public string ToString(string format); public string ToString(string format, IFormatProvider provider); Return Value The method returns a string that represents the value of the current ...

Read More
Showing 171–180 of 1,951 articles
« Prev 1 16 17 18 19 20 196 Next »
Advertisements