Server Side Programming Articles

Page 707 of 2109

Get an ICollection containing the keys in HybridDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 138 Views

To get an ICollection containing the keys in HybridDictionary, you use the Keys property. The HybridDictionary class is part of the System.Collections.Specialized namespace and provides a collection that uses a ListDictionary for small collections and switches to a Hashtable for larger collections automatically. The Keys property returns an ICollection that contains all the keys in the dictionary, which can then be iterated over or copied to an array. Syntax Following is the syntax for accessing the Keys property − ICollection keys = hybridDictionary.Keys; To copy keys to an array − string[] ...

Read More

C# Check if HybridDictionary is read only

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 141 Views

The HybridDictionary class in C# provides a collection that uses a ListDictionary for small collections and switches to a Hashtable for larger collections. To check if a HybridDictionary is read-only, you can use the IsReadOnly property. Syntax Following is the syntax to check if a HybridDictionary is read-only − bool isReadOnly = hybridDictionary.IsReadOnly; Return Value The IsReadOnly property returns a bool value − true − if the HybridDictionary is read-only false − if the HybridDictionary allows modifications HybridDictionary Properties IsReadOnly ...

Read More

How to get Second Element of the Tuple in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 370 Views

In C#, tuples are data structures that hold multiple values of different types. To access the second element of a tuple, you use the Item2 property. This property is available for all tuples that have at least two elements. Syntax Following is the syntax for accessing the second element of a tuple − var secondElement = tuple.Item2; You can also use tuple deconstruction to extract specific elements − var (first, second, _) = tuple; // _ ignores third element Using Item2 Property The Item2 property provides direct access ...

Read More

Remove element at specified index of Collection in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 234 Views

To remove an element at a specified index from a Collection in C#, you use the RemoveAt() method. This method removes the element at the specified zero-based index and shifts all subsequent elements down by one position. Syntax Following is the syntax for the RemoveAt() method − collection.RemoveAt(index); Parameters index − The zero-based index of the element to remove. Must be a valid index within the collection bounds. Using RemoveAt() for Single Element Removal The following example demonstrates removing a single element at index 3 from a Collection − ...

Read More

Remove elements from a HashSet with conditions defined by the predicate in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 371 Views

The RemoveWhere method in C# allows you to remove elements from a HashSet based on conditions defined by a predicate function. This method takes a delegate that returns true for elements that should be removed and false for elements that should be kept. Syntax Following is the syntax for using RemoveWhere method − public int RemoveWhere(Predicate match) Parameters match − A predicate delegate that defines the conditions for removal. Returns true for elements to be removed. Return Value Returns an int representing the number of elements that were removed ...

Read More

Remove elements from a SortedSet that match the predicate in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 363 Views

The RemoveWhere method in C# allows you to remove elements from a SortedSet based on a specified condition or predicate. This method evaluates each element against the predicate function and removes all elements that satisfy the condition. Syntax Following is the syntax for the RemoveWhere method − public int RemoveWhere(Predicate match) Parameters match: A Predicate delegate that defines the conditions of the elements to remove. The predicate returns true for elements that should be removed. Return Value The method returns an int representing the number of elements removed from the SortedSet. ...

Read More

Get or set the value associated with specified key in ListDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 165 Views

The ListDictionary class in C# provides an indexer that allows you to get or set values using a specified key. The indexer dict[key] provides convenient access to elements in the dictionary by their key. ListDictionary is part of the System.Collections.Specialized namespace and is optimized for small collections where the number of elements is usually 10 or fewer. Syntax Following is the syntax for getting a value using the indexer − object value = listDictionary[key]; Following is the syntax for setting a value using the indexer − listDictionary[key] = value; ...

Read More

Check if two StringCollection objects are equal in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 210 Views

In C#, checking if two StringCollection objects are equal is not as straightforward as it might seem. The default Equals() method only checks for reference equality, not content equality. This means two collections with identical elements will return false unless they reference the same object. Understanding StringCollection Equality The StringCollection class inherits the default Equals() method from Object, which performs reference comparison. To check for content equality, you need to implement custom comparison logic. StringCollection Equality Types Reference Equality strCol1.Equals(strCol2) Returns true only if ...

Read More

Check if two StringDictionary objects are equal or not in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 212 Views

The StringDictionary class in C# is a specialized collection that stores key-value pairs as strings. When comparing two StringDictionary objects for equality, it's important to understand that the default Equals()

Read More

Get or set the value associated with specified key in SortedList in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 161 Views

In C#, the SortedList collection allows you to get or set values using the indexer syntax with square brackets. The indexer property list[key] provides both read and write access to values associated with specific keys in the sorted list. Syntax Following is the syntax for getting a value from SortedList − object value = sortedList[key]; Following is the syntax for setting a value in SortedList − sortedList[key] = value; If the key exists, it updates the value. If the key doesn't exist, it adds a new key-value pair. Getting ...

Read More
Showing 7061–7070 of 21,090 articles
« Prev 1 705 706 707 708 709 2109 Next »
Advertisements