AmitDiwan

AmitDiwan

8,392 Articles Published

Articles by AmitDiwan

Page 227 of 840

DateTime.ToUniversalTime() Method in C#

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

The DateTime.ToUniversalTime() method in C# is used to convert the value of the current DateTime object to Coordinated Universal Time (UTC). This method is essential when working with applications that handle multiple time zones or need to store timestamps in a universal format. Syntax Following is the syntax − public DateTime ToUniversalTime(); Return Value Returns a DateTime object whose value is equivalent to the current DateTime object converted to UTC. If the current DateTime object represents a local time, it is converted to UTC using the system's time zone information. If it already ...

Read More

UInt16.CompareTo() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 236 Views

The UInt16.CompareTo() method in C# is used to compare the current instance to a specified object or UInt16 and returns an indication of their relative values. This method is essential for sorting operations and conditional comparisons involving unsigned 16-bit integers. Syntax The UInt16.CompareTo() method has two overloads − public int CompareTo(object val); public int CompareTo(ushort val); Parameters val − In the first overload, it is an object to compare. In the second overload, it is an unsigned 16-bit integer to compare. Return Value The method returns an ...

Read More

Boolean.TryParse() Method in C#

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

The Boolean.TryParse() method in C# safely converts a string representation of a logical value to its Boolean equivalent. Unlike Boolean.Parse(), this method returns true if the conversion succeeds and false if it fails, without throwing exceptions. Syntax Following is the syntax − public static bool TryParse(string value, out bool result); Parameters value − A string containing the value to convert. result − When this method returns, contains the Boolean value equivalent to the value contained in value, if the conversion succeeded, or false if the conversion failed. ...

Read More

Byte.CompareTo(Byte) Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 203 Views

The Byte.CompareTo(Byte) method in C# is used to compare the current byte instance to a specified 8-bit unsigned integer and returns an indication of their relative values. This method is useful for sorting operations and determining the relative ordering of byte values. Syntax Following is the syntax − public int CompareTo(byte value); Parameters value: An 8-bit unsigned integer to compare with the current instance. Return Value The method returns an integer that indicates the relative values of the compared instances: Less than zero: The current instance is less ...

Read More

UInt16.Equals Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 190 Views

The UInt16.Equals() method in C# returns a value indicating whether this instance is equal to a specified object or UInt16. This method provides two overloads: one for comparing with any object, and another specifically for comparing with another ushort value. Syntax Following are the two overloaded syntax forms − public override bool Equals (object ob); public bool Equals (ushort ob); Parameters ob (first overload) − An object to compare to this instance. ob (second overload) − The 16-bit unsigned integer to compare to this instance. Return Value Returns true ...

Read More

Byte.CompareTo(Object) Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 156 Views

The Byte.CompareTo(Object) method in C# compares the current byte instance to a specified object and returns an integer that indicates their relative values. This method is useful for sorting operations and determining the ordering relationship between byte values. Syntax Following is the syntax − public int CompareTo(object val); Parameters val − An object to compare, or null. Return Value The method returns an integer with the following meaning − Less than zero − The current instance is less than the value. Zero − The current instance ...

Read More

Byte.Equals(Byte) Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 368 Views

The Byte.Equals(Byte) method in C# returns a value indicating whether this instance and a specified Byte object represent the same value. This method provides a reliable way to compare two byte values for equality. Syntax Following is the syntax − public bool Equals(byte obj); Parameters obj − A byte object to compare to this instance. Return Value Returns true if obj has the same value as this instance; otherwise, false. Using Byte.Equals() for Value Comparison Example using System; public class Demo { public static ...

Read More

DateTimeOffset.AddMinutes() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 461 Views

The DateTimeOffset.AddMinutes() method in C# adds a specified number of whole and fractional minutes to a DateTimeOffset instance. This method returns a new DateTimeOffset object with the updated time while preserving the original offset from UTC. The method is particularly useful when working with time-zone aware calculations, as it maintains the timezone offset information throughout the operation. Syntax Following is the syntax − public DateTimeOffset AddMinutes(double minutes); Parameters minutes − A double value representing the number of minutes to add. Can be positive (to add) or negative (to subtract). Fractional values ...

Read More

UInt16.GetTypeCode() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 156 Views

The UInt16.GetTypeCode() method in C# is used to return the TypeCode for value type UInt16. This method is part of the IConvertible interface and provides a way to identify the underlying data type at runtime. The TypeCode enumeration represents different data types in .NET, and for all UInt16 values, this method always returns TypeCode.UInt16. Syntax Following is the syntax for the UInt16.GetTypeCode() method − public TypeCode GetTypeCode(); Return Value This method returns TypeCode.UInt16, which is the enumerated constant for the UInt16 data type. Using GetTypeCode() with Different UInt16 Values Example ...

Read More

DateTimeOffset.AddMonths() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 429 Views

The DateTimeOffset.AddMonths() method in C# is used to add a specified number of months to a DateTimeOffset instance. This method returns a new DateTimeOffset object with the month value adjusted while preserving the time zone offset information. Syntax Following is the syntax for the AddMonths() method − public DateTimeOffset AddMonths(int months); Parameters months − An integer representing the number of months to add. Use a positive value to add months or a negative value to subtract months. Return Value Returns a new DateTimeOffset object that represents the date and time that ...

Read More
Showing 2261–2270 of 8,392 articles
« Prev 1 225 226 227 228 229 840 Next »
Advertisements