Server Side Programming Articles

Page 709 of 2109

Get the number of strings in StringCollection in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 128 Views

The StringCollection class in C# provides a specialized collection for storing strings. To get the number of strings in a StringCollection, use the Count property, which returns an integer representing the total number of elements in the collection. Syntax Following is the syntax for accessing the Count property − int count = stringCollection.Count; Using Count Property with Basic StringCollection Example using System; using System.Collections.Specialized; public class Demo { public static void Main() { StringCollection strCol = new StringCollection(); ...

Read More

Remove the element with the specified key from a SortedList in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 312 Views

The SortedList class in C# provides the Remove() method to remove an element with a specified key. When you remove an element, the SortedList automatically adjusts its internal structure to maintain the sorted order of the remaining elements. Syntax Following is the syntax for removing an element from a SortedList − sortedList.Remove(key); Parameters key: The key of the element to remove from the SortedList. Using Remove() with String Keys This example demonstrates removing an element with a string key from a SortedList − using System; ...

Read More

Check if two OrderedDictionary objects are equal in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 167 Views

The OrderedDictionary class in C# represents a collection of key-value pairs that are accessible by both key and index. When comparing two OrderedDictionary objects for equality, you need to understand that the default Equals() method performs reference equality, not content equality. The Equals() method only returns true if both variables reference the same object in memory. For content-based comparison, you need a custom implementation. Syntax Following is the syntax for using the Equals() method − bool isEqual = dict1.Equals(dict2); Using Reference Equality (Default Behavior) Different Objects with Same Content using ...

Read More

Check if two SortedList objects are equal in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 186 Views

To check if two SortedList objects are equal in C#, you can use the Equals() method. However, it's important to understand that this method checks for reference equality, not content equality. Two SortedList objects are considered equal only if they reference the same object in memory. Syntax Following is the syntax for checking equality between two SortedList objects − bool isEqual = sortedList1.Equals(sortedList2); Using Equals() for Reference Equality The Equals() method returns true only when both variables reference the same SortedList object − using System; using System.Collections; public class Demo ...

Read More

Remove the entry at specified index from OrderedDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 143 Views

The OrderedDictionary class in C# provides the RemoveAt() method to remove an entry at a specified index. This method removes the key-value pair located at the given zero-based index position while maintaining the order of remaining elements. Syntax Following is the syntax for the RemoveAt() method − public void RemoveAt(int index) Parameters index − The zero-based index of the entry to remove from the OrderedDictionary. Using RemoveAt() Method The following example demonstrates removing an entry at a specific index from an OrderedDictionary − using System; using System.Collections; ...

Read More

Remove the entry with specified key from ListDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 156 Views

The ListDictionary class in C# provides the Remove() method to delete entries by their key. This method removes the key-value pair associated with the specified key from the dictionary and returns no value. Syntax Following is the syntax for removing an entry from a ListDictionary − listDictionary.Remove(key); Parameters key − The key of the entry to remove from the ListDictionary. Return Value The Remove() does not return a value. It simply removes the specified key-value pair if the key exists. Using Remove() Method Here's how to remove ...

Read More

Check if the specified string is in the StringCollection in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 125 Views

To check if a specified string exists in a StringCollection, you use the Contains() method. The StringCollection class is part of the System.Collections.Specialized namespace and provides a collection specifically designed for storing strings. Syntax Following is the syntax for checking if a string exists in StringCollection − bool result = stringCollection.Contains(string value); Parameters value − The string to search for in the StringCollection. Return Value The Contains()

Read More

Check if the StringCollection is read-only in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 169 Views

The StringCollection class in C# represents a collection of strings and provides an IsReadOnly property to check if the collection is read-only. A read-only collection cannot be modified after creation, meaning you cannot add, remove, or modify elements. By default, a StringCollection created using the parameterless constructor is not read-only, allowing modifications like adding or removing strings. Syntax Following is the syntax for checking if a StringCollection is read-only − bool isReadOnly = stringCollection.IsReadOnly; Return Value The IsReadOnly property returns a bool value − true − The StringCollection is read-only ...

Read More

Remove the first occurrence from the StringCollection in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 163 Views

The StringCollection class in C# provides the Remove() method to remove the first occurrence of a specified string from the collection. This method is useful when you need to eliminate duplicate values or specific elements from your string collection. Syntax Following is the syntax for removing the first occurrence from a StringCollection − stringCollection.Remove(string value); Parameters value − The string to remove from the StringCollection. The method removes only the first occurrence if multiple instances exist. Return Value The Remove() does not return a value. It modifies ...

Read More

Removing the specified key entry from HybridDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 213 Views

The HybridDictionary class in C# provides the Remove() method to remove a specified key-value pair from the collection. This method takes the key as a parameter and removes the corresponding entry if it exists. Syntax Following is the syntax for removing a key entry from HybridDictionary − public void Remove(object key); Parameters key − The key of the element to remove from the HybridDictionary. How It Works The Remove()

Read More
Showing 7081–7090 of 21,090 articles
« Prev 1 707 708 709 710 711 2109 Next »
Advertisements