Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Csharp Articles
Page 181 of 196
Char.ToString() Method in C#
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 MoreMath.BigMul() Method in C#
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 MoreDecimal.ToUInt16() Method in C#
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 MoreDateTime.SpecifyKind() Method in C#
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 MoreDateTimeOffset.CompareTo() Method in C#
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 MoreHow to create 2-tuple or pair tuple in C#?
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 MoreDateTime.Subtract() Method in C#
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 MoreDateTime.ToBinary() Method in C#
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 MoreDateTime.ToFileTime() Method in C#
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 MoreBitConverter.DoubleToInt64Bits() Method in C#
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