AmitDiwan

AmitDiwan

8,392 Articles Published

Articles by AmitDiwan

Page 194 of 840

How to add key/value pairs in SortedList in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 330 Views

A SortedList in C# is a collection that stores key/value pairs sorted by keys. The Add() method is the primary way to insert key/value pairs into a SortedList, automatically maintaining sorted order based on the keys. Syntax Following is the syntax for adding key/value pairs to a SortedList − SortedList sortedList = new SortedList(); sortedList.Add(key, value); Parameters key − The key of the element to add. Cannot be null and must be unique. value − The value of the element to add. Can be null. Using ...

Read More

Convert the value of the current DateTime object to a Windows file time in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 362 Views

The DateTime.ToFileTime() method in C# converts the value of the current DateTime object to a Windows file time. A Windows file time is a 64-bit value that represents the number of 100-nanosecond intervals that have elapsed since 12:00 midnight, January 1, 1601 A.D. (UTC). This method is commonly used when working with file system operations, as Windows stores file timestamps in this format internally. Syntax Following is the syntax for the ToFileTime() method − public long ToFileTime() Return Value The method returns a long value representing the Windows file time equivalent of ...

Read More

BitConverter.ToInt16() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 343 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 320 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

How to create a SortedSet in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 155 Views

A SortedSet in C# is a collection that maintains its elements in sorted order automatically. It belongs to the System.Collections.Generic namespace and ensures that duplicate elements are not allowed while keeping all elements sorted based on their natural ordering or a custom comparer. Syntax Following is the syntax for creating a SortedSet − SortedSet setName = new SortedSet(); You can also initialize with an existing collection − SortedSet setName = new SortedSet(existingCollection); To use a custom comparer − SortedSet setName = new SortedSet(comparer); Using SortedSet with ...

Read More

Convert the specified double-precision floating point number to a 64-bit signed integer in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 436 Views

To convert a double-precision floating point number to its 64-bit signed integer representation, C# provides the BitConverter.DoubleToInt64Bits() method. This method converts the binary representation of a double value into a long integer without changing the underlying bit pattern. This is useful when you need to examine the internal binary structure of floating-point numbers or perform low-level operations on their bit representations. Syntax Following is the syntax for converting a double to its 64-bit signed integer representation − long result = BitConverter.DoubleToInt64Bits(doubleValue); Parameters The DoubleToInt64Bits() method takes one parameter − value: ...

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

Convert the value of the specified string to its equivalent Unicode character in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 433 Views

To convert the value of a specified string to its equivalent Unicode character in C#, you can use the Char.TryParse method. This method attempts to convert a string representation to a single Unicode character and returns a boolean indicating whether the conversion was successful. Syntax Following is the syntax for Char.TryParse method − public static bool TryParse(string s, out char result) Parameters s − The string to convert. Must be exactly one character long for successful conversion. result − When the method returns, contains the Unicode character equivalent if ...

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

Reinterpret 64-bit signed integer to a double-precision floating point number in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 563 Views

The BitConverter.Int64BitsToDouble() method in C# reinterprets the bit pattern of a 64-bit signed integer as a double-precision floating point number. This is not a numeric conversion − it treats the integer's binary representation as if it were the IEEE 754 double format. Syntax Following is the syntax for the Int64BitsToDouble method − public static double Int64BitsToDouble(long value) Parameters value − A 64-bit signed integer whose bit pattern will be reinterpreted as a double. Return Value Returns a double-precision floating point number whose bit representation is equivalent to the input ...

Read More
Showing 1931–1940 of 8,392 articles
« Prev 1 192 193 194 195 196 840 Next »
Advertisements