Server Side Programming Articles

Page 855 of 2109

Type.GetEnumName() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 123 Views

The Type.GetEnumName() method in C# returns the name of the constant that has the specified value for the current enumeration type. This method is useful when you need to convert an enum value back to its string representation. Syntax Following is the syntax − public virtual string GetEnumName(object value); Parameters value − An object whose value is a constant in the current enumeration type. Return Value Returns a string containing the name of the enumerated constant that has the specified value, or null if no such constant is found. ...

Read More

DateTimeOffset.FromFileTime() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 97 Views

The DateTimeOffset.FromFileTime() method in C# converts a Windows file time value (in ticks) to an equivalent DateTimeOffset representing the local time. This method is useful when working with file timestamps or Windows-specific time representations. Syntax Following is the syntax for the DateTimeOffset.FromFileTime() method − public static DateTimeOffset FromFileTime(long fileTime); Parameters fileTime: A Windows file time expressed in ticks. This represents the number of 100-nanosecond intervals that have elapsed since 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC). Return Value Returns a DateTimeOffset object that represents the date and ...

Read More

DateTimeOffset.FromUnixTimeMilliseconds() Method in C#

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

The DateTimeOffset.FromUnixTimeMilliseconds() method in C# is used to convert a Unix timestamp expressed as the number of milliseconds that have elapsed since 1970-01-01T00:00:00Z (Unix epoch) to a DateTimeOffset value. Unix timestamps are commonly used in web APIs, databases, and cross-platform applications as a standard way to represent time. This method provides an easy conversion from the Unix millisecond format to C#'s DateTimeOffset structure. Syntax Following is the syntax for the method − public static DateTimeOffset FromUnixTimeMilliseconds(long milliseconds); Parameters milliseconds − A long value representing the number of milliseconds that have elapsed ...

Read More

DateTimeOffset.FromUnixTimeSeconds() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 994 Views

The DateTimeOffset.FromUnixTimeSeconds() method in C# is used to convert a Unix timestamp (expressed as seconds since January 1, 1970, 00:00:00 UTC) to a DateTimeOffset value. This method is particularly useful when working with Unix-based systems or APIs that return timestamps in Unix format. Syntax Following is the syntax − public static DateTimeOffset FromUnixTimeSeconds(long seconds); Parameters seconds: A Unix time, expressed as the number of seconds that have elapsed since 1970-01-01T00:00:00Z (January 1, 1970, at 12:00 AM UTC). This parameter accepts both positive and negative values. Return Value Returns a DateTimeOffset object ...

Read More

How to create 1-Tuple or Singleton Tuple in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 214 Views

The Tuple class in C# represents a 1-tuple or singleton tuple, which is a data structure that holds a single element. Unlike regular variables, tuples provide additional functionality and can be useful when you need to treat a single value as part of a tuple-based system. Syntax Following is the syntax for creating a 1-tuple − Tuple tupleName = new Tuple(value); Accessing the value using the Item1 property − T value = tupleName.Item1; Using 1-Tuple with Integer Values The following example demonstrates creating and using a 1-tuple with an ...

Read More

Type.GetEnumNames() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 145 Views

The Type.GetEnumNames() method in C# is used to return the names of the members of the current enumeration type as an array of strings. This method is particularly useful when you need to dynamically retrieve all the constant names defined in an enum type at runtime. Syntax Following is the syntax for the GetEnumNames() method − public virtual string[] GetEnumNames(); Return Value This method returns a string array containing the names of the enumeration constants. If the current type is not an enumeration type, it throws an ArgumentException. Using GetEnumNames() with Enum ...

Read More

Type.GetEnumUnderlyingType() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 159 Views

The Type.GetEnumUnderlyingType() method in C# returns the underlying data type of an enumeration. By default, enums are based on int, but they can also be based on other integral types like byte, short, long, etc. Syntax Following is the syntax − public virtual Type GetEnumUnderlyingType(); Return Value Returns a Type object representing the underlying type of the enumeration. Throws ArgumentException if the current type is not an enumeration. Using GetEnumUnderlyingType() with Default Enum Let us see an example that demonstrates getting the underlying type of a default enum − ...

Read More

Type.GetEnumValues() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 435 Views

The Type.GetEnumValues() method in C# returns an array containing the values of all constants in an enumeration type. This method is useful when you need to iterate through all possible values of an enum or perform operations on the entire set of enum values. Syntax Following is the syntax for the GetEnumValues() method − public virtual Array GetEnumValues(); Return Value Returns an Array that contains the values of the constants in the current enumeration type. The elements of the array are sorted by the binary values of the enumeration constants. Using GetEnumValues() ...

Read More

Decimal.ToOACurrency() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 150 Views

The Decimal.ToOACurrency() method in C# converts a decimal value to an OLE Automation Currency value, which is represented as a 64-bit signed integer. OLE Automation Currency is a fixed-point data type that stores currency values with 4 decimal places of precision, making it suitable for financial calculations where precision is critical. The method multiplies the decimal value by 10, 000 to preserve 4 decimal places in the integer representation. This format is commonly used in COM interop scenarios and legacy systems that require OLE Automation compatibility. Syntax Following is the syntax for the Decimal.ToOACurrency() method − ...

Read More

Decimal.ToSByte() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 99 Views

The Decimal.ToSByte() method in C# converts a decimal value to an equivalent 8-bit signed integer (sbyte). This method performs truncation, discarding any fractional part and returning only the integer portion of the decimal value. The sbyte data type can hold values from -128 to 127. If the decimal value is outside this range, an OverflowException will be thrown. Syntax Following is the syntax − public static sbyte ToSByte(decimal val); Parameters val − The decimal number to convert to an sbyte. Return Value Returns an sbyte value ...

Read More
Showing 8541–8550 of 21,090 articles
« Prev 1 853 854 855 856 857 2109 Next »
Advertisements