Server Side Programming Articles

Page 836 of 2109

C# Program to find a key in Dictionary

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

In C#, a Dictionary is a collection that stores key-value pairs. To check if a specific key exists in a Dictionary, you can use the ContainsKey() method, which returns true if the key is found and false otherwise. Syntax Following is the syntax for using the ContainsKey() method − bool result = dictionary.ContainsKey(key); Parameters key − The key to locate in the Dictionary. Return Value Returns true if the Dictionary contains an element with the specified key; otherwise, false. Using ContainsKey() Method The most straightforward way to ...

Read More

"." custom specifier in C#

Samual Sam
Samual Sam
Updated on 17-Mar-2026 271 Views

The "." custom format specifier in C# adds a localized decimal separator into the output string. It determines the exact position where the decimal point will appear in the formatted numeric value. The first period in the format string determines the location of the decimal separator in the formatted value. Any additional periods are ignored and treated as literal characters. Syntax Following is the syntax for using the "." custom format specifier − number.ToString("format_with_decimal_point") String.Format("format_with_decimal_point", number) Where the format string contains a period (.) to specify decimal separator placement. How It Works ...

Read More

Size of a Three-dimensional array in C#

George John
George John
Updated on 17-Mar-2026 1K+ Views

To get the size of a three-dimensional array in C#, you can use the GetLength() method to retrieve the size of individual dimensions, or the Length property to get the total number of elements across all dimensions. Syntax Following is the syntax for getting the size of specific dimensions − array.GetLength(dimensionIndex) Following is the syntax for getting the total number of elements − array.Length Parameters dimensionIndex − A zero-based integer representing the dimension index (0 for first dimension, 1 for second dimension, 2 for third dimension). ...

Read More

FormatException in C#

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

A FormatException is thrown when the format of an argument is invalid or cannot be converted to the expected data type. This commonly occurs when attempting to parse a string that doesn't match the expected format for numeric or date types. Common Scenarios FormatException typically occurs in these situations − Parsing a non-numeric string as a number using int.Parse(), double.Parse(), etc. Converting a string with decimal points to an integer Parsing invalid date formats using DateTime.Parse() Using incorrect format specifiers in string formatting Using int.Parse() with ...

Read More

C# Linq Except Method

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 3K+ Views

The Except() method in LINQ is used to find the set difference between two collections. It returns elements from the first collection that are not present in the second collection, effectively performing a set subtraction operation. Syntax Following is the syntax for the Except() method − public static IEnumerable Except( this IEnumerable first, IEnumerable second ) With custom equality comparer − public static IEnumerable Except( this IEnumerable first, IEnumerable second, IEqualityComparer comparer ...

Read More

C# Linq ElementAt Method

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

The ElementAt() method in C# LINQ returns the element at a specified index position in a sequence. It is part of the LINQ extension methods and can be used with any IEnumerable collection. The ElementAt() method throws an ArgumentOutOfRangeException if the index is out of bounds. For safer access, you can use ElementAtOrDefault(), which returns the default value for the type if the index is invalid. Syntax Following is the syntax for the ElementAt() method − public static TSource ElementAt(this IEnumerable source, int index) Following is the syntax for the ElementAtOrDefault() method − ...

Read More

Sortable ("s") Format Specifier in C#

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 562 Views

The Sortable ("s") format specifier in C# represents a standardized date and time format that produces ISO 8601-compliant strings. This format is particularly useful for sorting dates chronologically as strings and for data interchange between different systems. The "s" format specifier is defined by the DateTimeFormatInfo.SortableDateTimePattern property and follows a consistent pattern regardless of the current culture settings. Syntax The sortable format specifier uses the following syntax − DateTime.ToString("s") This corresponds to the custom format pattern − yyyy'-'MM'-'dd'T'HH':'mm':'ss Format Pattern Breakdown Sortable Format Pattern: ...

Read More

C# Linq First() Method

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

The First() method in C# LINQ is used to return the first element from a collection such as arrays, lists, or any IEnumerable sequence. It throws an exception if the collection is empty. Syntax Following is the syntax for the First() method − collection.First() collection.First(predicate) Parameters predicate (optional) − A function to test each element for a condition. Return Value Returns the first element in the collection or the first element that satisfies the condition. Throws InvalidOperationException if no element is found. Using First() Without Predicate The ...

Read More

C# Math.DivRem Method

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

The Math.DivRem method in C# performs integer division and returns both the quotient and remainder in a single operation. This is more efficient than performing separate division and modulo operations when you need both results. Syntax Following is the syntax for the Math.DivRem method − public static int Math.DivRem(int a, int b, out int result); public static long Math.DivRem(long a, long b, out long result); Parameters a − The dividend (number to be divided) b − The divisor (number to divide by) result − An out parameter that receives the remainder ...

Read More

Represent Int32 as a String in C#

Samual Sam
Samual Sam
Updated on 17-Mar-2026 353 Views

The Int32 type in C# represents a 32-bit signed integer. To convert an Int32 value to its string representation, you can use the ToString() method. This method converts the numeric value into a readable string format. Syntax Following is the syntax for converting an Int32 to string using ToString() − int number = value; string result = number.ToString(); You can also use format specifiers with ToString() − string result = number.ToString("format"); Using ToString() Method Basic Conversion Example The simplest way to convert an Int32 to string is using ...

Read More
Showing 8351–8360 of 21,090 articles
« Prev 1 834 835 836 837 838 2109 Next »
Advertisements