AmitDiwan

AmitDiwan

8,392 Articles Published

Articles by AmitDiwan

Page 178 of 840

Remove from the specified index of a SortedList in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 235 Views

The SortedList class in C# provides the RemoveAt() method to remove a key-value pair from a specified index. The RemoveAt() method removes the element at the specified zero-based index and automatically shifts the remaining elements to fill the gap. Syntax Following is the syntax for the RemoveAt() method − public virtual void RemoveAt(int index) Parameters index − The zero-based index of the element to remove. Key Points The index is zero-based, meaning the first element is at index 0. After removal, all elements at higher indices are shifted ...

Read More

How to create a StringCollection in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 180 Views

The StringCollection class in C# is a specialized collection that stores only string values. It is part of the System.Collections.Specialized namespace and provides methods to add, remove, and manipulate strings efficiently. StringCollection is useful when you need to work exclusively with string data and want type safety without the overhead of generic collections. Syntax Following is the syntax for creating a StringCollection − StringCollection collection = new StringCollection(); To add multiple strings at once using an array − string[] array = {"string1", "string2", "string3"}; collection.AddRange(array); Creating and Populating a ...

Read More

Get the TypeCode for value type Char in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 268 Views

The TypeCode for a char value type in C# can be obtained using the GetTypeCode() method. This method returns TypeCode.Char, which is an enumeration value that identifies the char data type. The GetTypeCode() method is inherited from the IConvertible interface and provides a way to determine the underlying type of a value at runtime. Syntax Following is the syntax to get the TypeCode for a char value − TypeCode typeCode = charVariable.GetTypeCode(); Return Value The method returns TypeCode.Char for char data types, which is part of the TypeCode enumeration. Using GetTypeCode() ...

Read More

How to get all elements of a List that match the conditions specified by the predicate in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 708 Views

To get all elements of a List that match specific conditions, C# provides the FindAll method which accepts a predicate − a delegate that defines the filtering criteria. This method returns a new List containing only the elements that satisfy the condition. Syntax Following is the syntax for using FindAll with a predicate − List result = list.FindAll(predicate); The predicate can be defined as a method, lambda expression, or anonymous delegate − // Method predicate private static bool MethodName(T item) { return condition; } // Lambda expression predicate ...

Read More

Check whether the specified Unicode character is a letter or a decimal digit in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 237 Views

To check whether the specified Unicode character is a letter or a decimal digit in C#, use the Char.IsLetterOrDigit() method. This method returns true if the character is a letter (uppercase or lowercase) or a decimal digit (0-9), and false otherwise. Syntax Following is the syntax for the Char.IsLetterOrDigit() method − public static bool IsLetterOrDigit(char c) Parameters c: The Unicode character to evaluate. Return Value Returns true if the character is a letter or decimal digit; otherwise, false. Using IsLetterOrDigit with Decimal Digits Example ...

Read More

How to get the HashCode of the tuple in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 247 Views

To get the HashCode of a tuple in C#, you can use the GetHashCode() method. This method returns an integer hash code that represents the tuple's value. Tuples with identical values will have the same hash code, while tuples with different values will typically have different hash codes. Syntax Following is the syntax for getting the hash code of a tuple − int hashCode = tuple.GetHashCode(); Return Value The GetHashCode() method returns a 32-bit signed integer that serves as a hash code for the tuple. Equal tuples will always return the same hash ...

Read More

Check whether the Unicode character is a lowercase letter in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 311 Views

To check whether a Unicode character is a lowercase letter in C#, we use the Char.IsLower() method. This method examines the Unicode character and returns true if it represents a lowercase letter according to Unicode standards, and false otherwise. Syntax Following is the syntax for the Char.IsLower() method − public static bool IsLower(char c) Parameters c − The Unicode character to evaluate Return Value The method returns a bool value − true if the character is a lowercase letter false if the character is not a lowercase ...

Read More

Compare this instance is equal to a specified object or Int64 in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 138 Views

The Equals() method in C# is used to compare whether the current instance of a long (Int64) is equal to a specified object or another Int64 value. This method performs value-based comparison and returns a boolean result. Syntax Following is the syntax for the Equals() method − public bool Equals(long value) public override bool Equals(object obj) Parameters value − A long value to compare with the current instance. obj − An object to compare with the current instance. Return Value Returns true if the current ...

Read More

Get the hash code for the current Int64 instance in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 191 Views

The GetHashCode() method in C# returns a hash code for the current Int64 instance. This method is inherited from the Object class and is commonly used in hash-based collections like Dictionary and HashSet to efficiently store and retrieve values. Hash codes are 32-bit integers that provide a quick way to compare objects for equality. Two equal Int64 values will always have the same hash code, but different values may occasionally produce the same hash code (called a collision). Syntax Following is the syntax for getting the hash code of an Int64 value − public override ...

Read More

Check whether the specified Unicode character is a punctuation mark in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 332 Views

The Char.IsPunctuation() method in C# determines whether a specified Unicode character is classified as a punctuation mark. This method returns true if the character belongs to any punctuation category, otherwise it returns false. Punctuation marks include characters like periods, commas, semicolons, exclamation points, question marks, brackets, and other symbols used for punctuation in text. Syntax Following is the syntax for the Char.IsPunctuation() method − public static bool IsPunctuation(char c) Parameters c − The Unicode character to evaluate. Return Value Returns true if the character is a ...

Read More
Showing 1771–1780 of 8,392 articles
« Prev 1 176 177 178 179 180 840 Next »
Advertisements