Server Side Programming Articles

Page 829 of 2109

C# Enum ToString() Method

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 3K+ Views

The ToString() method in C# enums converts the enum value to its equivalent string representation. This method provides different formatting options to display enum values as either their names or underlying numeric values. Syntax Following are the common syntax forms for enum ToString() method − enumValue.ToString() // Returns name enumValue.ToString("G") // Returns name (General format) enumValue.ToString("d") // Returns decimal value enumValue.ToString("D") // Returns decimal value Parameters ...

Read More

C# Enum Parse Method

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 2K+ Views

The Enum.Parse method in C# converts the string representation of an enum constant name or its numeric value into an equivalent enumerated object. This method is essential when you need to convert string data back into strongly-typed enum values. Syntax Following are the main syntax forms for Enum.Parse − // Basic syntax public static object Parse(Type enumType, string value) // With ignore case option public static object Parse(Type enumType, string value, bool ignoreCase) Parameters enumType − The type of the enumeration to parse to value − A string containing the name ...

Read More

Clear a Linked List in C#

George John
George John
Updated on 17-Mar-2026 246 Views

The Clear() method in C# is used to remove all nodes from a LinkedList. This method provides an efficient way to empty the entire linked list in a single operation, resetting the Count property to zero. Syntax Following is the syntax for the Clear() − linkedList.Clear(); Parameters The Clear() method takes no parameters. Return Value The Clear() method does not return any value. It is a void method that modifies the linked list in-place. LinkedList Clear() Operation Before Clear(): ...

Read More

Long Date ("D") Format Specifier in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 400 Views

The "D" format specifier in C# represents the long date format pattern. It displays dates in a culture-specific long format, showing the full day name, month name, day, and year without time information. The format string is defined by the culture's DateTimeFormatInfo.LongDatePattern property and varies based on the specified culture. Syntax Following is the syntax for using the "D" format specifier − DateTime.ToString("D") DateTime.ToString("D", CultureInfo) The default custom format string for English (US) culture is − dddd, dd MMMM yyyy Using "D" Format with Default Culture Example ...

Read More

How to negate the positive elements of an integer array in C#?

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 473 Views

Negating the positive elements of an integer array means converting all positive values to their negative counterparts while leaving negative and zero values unchanged. This operation is useful in various mathematical computations and data processing scenarios. Syntax Following is the basic syntax to check and negate positive elements − if (arr[i] > 0) arr[i] = -arr[i]; A complete loop structure to process all array elements − for (int i = 0; i < arr.Length; i++) { if (arr[i] > 0) ...

Read More

C# Currency ("C") Format Specifier

Samual Sam
Samual Sam
Updated on 17-Mar-2026 33K+ Views

The C format specifier (currency) is used to format numeric values as currency amounts. It automatically applies the appropriate currency symbol, decimal places, and thousands separators based on the current culture settings. Syntax Following is the syntax for using the currency format specifier − value.ToString("C") // Default currency format value.ToString("C3") // Currency with 3 decimal places value.ToString("C", culture) // Currency with specific culture The precision specifier (optional number after C) determines how many decimal ...

Read More

Remove an item from a Hashtable in C#

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 825 Views

The Hashtable class in C# provides the Remove() method to delete key-value pairs. The method takes the key as a parameter and removes the corresponding entry from the hashtable if it exists. Syntax Following is the syntax for removing an item from a Hashtable − hashtable.Remove(key); Parameters key − The key of the element to remove from the hashtable. Return Value The Remove()

Read More

C# Program to find a key in a Hashtable

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 518 Views

A Hashtable in C# is a collection of key-value pairs where each key is unique. To check if a specific key exists in a Hashtable, you can use the Contains() method or ContainsKey() method. Syntax Following is the syntax for creating a Hashtable and checking if a key exists − Hashtable hashtable = new Hashtable(); hashtable.Add(key, value); bool exists = hashtable.Contains(key); Alternatively, you can use ContainsKey() method − bool exists = hashtable.ContainsKey(key); Using Contains() Method The Contains() method returns true if the specified key exists in the Hashtable, otherwise ...

Read More

Convert.ToDouble Method in C#

Samual Sam
Samual Sam
Updated on 17-Mar-2026 11K+ Views

The Convert.ToDouble() method in C# converts a specified value to a double-precision floating-point number. This method is part of the Convert class and can handle various data types including integers, strings, booleans, and other numeric types. Syntax Following is the syntax for the Convert.ToDouble() method − public static double ToDouble(object value) public static double ToDouble(string value) public static double ToDouble(int value) public static double ToDouble(long value) public static double ToDouble(bool value) Parameters value − The value to be converted to a double-precision floating-point number. This can be of various types including object, string, ...

Read More

ContainsKey() method in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 322 Views

The ContainsKey() method in C# is used to check whether a specific key exists in a Hashtable or other collection types like Dictionary. This method returns true if the key is found, otherwise it returns false. Syntax Following is the syntax for the ContainsKey() method − bool ContainsKey(object key) Parameters key − The key to locate in the collection. Return Value Returns true if the key exists in the collection; otherwise, false. ContainsKey() Method Logic Hashtable ...

Read More
Showing 8281–8290 of 21,090 articles
« Prev 1 827 828 829 830 831 2109 Next »
Advertisements