Csharp Articles

Page 181 of 196

Char.ToString() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 217 Views

The Char.ToString() method in C# is used to convert a character to its equivalent string representation. This method is particularly useful when you need to convert a single character into a string for string operations or concatenation. Syntax Following is the syntax for the Char.ToString() method − public override string ToString(); Return Value The method returns a string object containing the character value converted to its string representation. Using Char.ToString() Method Example 1 - Converting Lowercase Character Let us see an example to convert a lowercase character to its string ...

Read More

Math.BigMul() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 304 Views

The Math.BigMul() method in C# is used to calculate the full product of two 32-bit integers. This method is particularly useful when multiplying large integers that might produce a result exceeding the range of a 32-bit integer, as it returns a 64-bit long value to accommodate the full product. Syntax Following is the syntax − public static long BigMul(int val1, int val2); Parameters val1: The first 32-bit integer to multiply val2: The second 32-bit integer to multiply Return Value Returns a long (64-bit integer) containing ...

Read More

Decimal.ToUInt16() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 106 Views

The Decimal.ToUInt16() method in C# is used to convert the value of the specified Decimal to the equivalent 16-bit unsigned integer (ushort). This method performs a narrowing conversion, truncating any fractional part. Syntax Following is the syntax − public static ushort ToUInt16(decimal val); Parameters val − The decimal number to convert to a 16-bit unsigned integer. Return Value Returns a ushort value that represents the converted decimal. The fractional part is truncated (not rounded). How It Works The method truncates the decimal value to the ...

Read More

DateTime.SpecifyKind() Method in C#

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

The DateTime.SpecifyKind() method in C# is used to create a new DateTime object that has the same number of ticks as the specified DateTime but is designated as either local time, Coordinated Universal Time (UTC), or neither, as indicated by the specified DateTimeKind value. This method is particularly useful when you have a DateTime value but need to explicitly specify its time zone context without changing the actual time value. The original DateTime remains unchanged − a new instance is returned with the specified Kind property. Syntax Following is the syntax for the DateTime.SpecifyKind() method − ...

Read More

DateTimeOffset.CompareTo() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 157 Views

The DateTimeOffset.CompareTo() method in C# compares the current DateTimeOffset object to a specified DateTimeOffset object and indicates whether the current object is earlier than, the same as, or later than the second DateTimeOffset object. It returns an integer value based on the comparison result − < 0 − If this object is earlier than the specified value 0 − If this object is the same as the specified value > 0 − If this object is later than the specified value Syntax Following is the syntax − public int CompareTo(DateTimeOffset value); ...

Read More

How to create 2-tuple or pair tuple in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 358 Views

The Tuple class in C# represents a 2-tuple, also known as a pair. A tuple is a data structure that contains a sequence of elements of different types. The 2-tuple holds exactly two values that can be accessed using Item1 and Item2 properties. 2-tuples are useful when you need to return two values from a method or group two related values together without creating a separate class. Syntax Following is the syntax for creating a 2-tuple − Tuple tuple = new Tuple(value1, value2); Accessing tuple elements − var firstValue = tuple.Item1; ...

Read More

DateTime.Subtract() Method in C#

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

The DateTime.Subtract() method in C# is used to subtract either a DateTime or a TimeSpan from the current DateTime instance. This method has two overloads: one subtracts a DateTime and returns the time difference as a TimeSpan, while the other subtracts a TimeSpan and returns a new DateTime. Syntax Following are the two overloads of the DateTime.Subtract() method − public TimeSpan Subtract(DateTime value); public DateTime Subtract(TimeSpan value); Parameters value − Either a DateTime instance to subtract from the current date, or a TimeSpan representing the duration to subtract. ...

Read More

DateTime.ToBinary() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 773 Views

The DateTime.ToBinary() method in C# is used to serialize the current DateTime object to a 64-bit binary value that can be used to recreate the DateTime object. The return value is a 64-bit signed integer that encodes both the date/time value and the DateTimeKind. Syntax Following is the syntax − public long ToBinary(); Return Value The method returns a long (64-bit signed integer) that represents the serialized DateTime. This binary value can later be used with DateTime.FromBinary() to reconstruct the original DateTime object. How It Works The binary representation encodes different ...

Read More

DateTime.ToFileTime() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 597 Views

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

Read More

BitConverter.DoubleToInt64Bits() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 137 Views

The BitConverter.DoubleToInt64Bits() method in C# converts a double-precision floating-point number to its 64-bit signed integer binary representation. This method is useful for examining the underlying binary structure of floating-point numbers or for low-level operations that require access to the raw bits. Syntax Following is the syntax for the DoubleToInt64Bits() method − public static long DoubleToInt64Bits(double value); Parameters value − The double-precision floating-point number to convert. Return Value Returns a 64-bit signed integer whose value is equivalent to the binary representation of the input double value. ...

Read More
Showing 1801–1810 of 1,951 articles
« Prev 1 179 180 181 182 183 196 Next »
Advertisements