Server Side Programming Articles

Page 711 of 2109

Get the number of key/value pairs in the StringDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 155 Views

The StringDictionary class in C# provides the Count property to get the number of key/value pairs stored in the dictionary. This property is useful for determining the size of the collection and performing operations based on the dictionary's length. Syntax Following is the syntax to get the count of key/value pairs in a StringDictionary − int count = stringDictionary.Count; Return Value The Count property returns an integer representing the number of key/value pairs currently stored in the StringDictionary. Using Count Property with Basic StringDictionary Example using System; using System.Collections; ...

Read More

Removing the node at the start of the LinkedList in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 145 Views

The LinkedList class in C# provides the RemoveFirst() method to remove the node at the start of the linked list. This method removes the first node and automatically updates the list's internal structure and count. Syntax Following is the syntax for removing the first node from a LinkedList − linkedList.RemoveFirst(); The method throws an InvalidOperationException if the LinkedList is empty. RemoveFirst() Operation One Two Three Four ...

Read More

Get an ICollection containing the keys in ListDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 137 Views

The ListDictionary class in C# provides a Keys property that returns an ICollection containing all the keys in the dictionary. This is useful when you need to iterate through or process only the keys without accessing their corresponding values. Syntax Following is the syntax to get the keys collection from a ListDictionary − ICollection keys = listDictionary.Keys; Return Value The Keys property returns an ICollection object that contains all the keys from the ListDictionary. The keys are returned in the same order as they were added to the dictionary. Using Keys Property ...

Read More

Get an ICollection containing the values in HybridDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 158 Views

The HybridDictionary class in C# provides the Values property that returns an ICollection containing all the values in the dictionary. This collection can be used to iterate through values or copy them to an array for further processing. Syntax Following is the syntax to get the values collection from a HybridDictionary − ICollection values = hybridDictionary.Values; To copy values to an array − hybridDictionary.Values.CopyTo(array, startIndex); How It Works The Values property returns an ICollection that contains all the values stored in the HybridDictionary. The order of values may vary ...

Read More

Get the last node of the LinkedList in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 365 Views

In C#, you can get the last node of a LinkedList using the Last property. This property returns a LinkedListNode object representing the last node in the list, or null if the list is empty. Syntax Following is the syntax to get the last node of a LinkedList − LinkedListNode lastNode = linkedList.Last; T lastValue = linkedList.Last.Value; Using Last Property with String LinkedList The following example demonstrates how to access the last node in a string LinkedList − using System; using System.Collections.Generic; public class Demo { public ...

Read More

Get the maximum value in the SortedSet in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 219 Views

The SortedSet class in C# provides the Max property to efficiently retrieve the maximum value from the collection. Since SortedSet maintains elements in sorted order, the maximum element is always the last element in the collection. Syntax Following is the syntax for getting the maximum value from a SortedSet − SortedSet sortedSet = new SortedSet(); T maxValue = sortedSet.Max; Properties Property Description Return Type Max Gets the maximum value in the SortedSet according to the comparer. T Min Gets the minimum value in the ...

Read More

Remove all objects from the Stack in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 229 Views

In C#, the Stack class provides the Clear() method to remove all objects from the Stack. This method efficiently removes every element from the Stack, leaving it empty with a count of zero. Syntax Following is the syntax for removing all objects from a Stack − stack.Clear(); Where stack is the instance of the Stack from which all elements need to be removed. How It Works The Clear()

Read More

Removing all entries from HybridDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 155 Views

A HybridDictionary in C# is part of the System.Collections.Specialized namespace that automatically switches between a ListDictionary and Hashtable based on the number of elements. To remove all entries from a HybridDictionary, you use the Clear() method. Syntax Following is the syntax for removing all entries from a HybridDictionary − hybridDictionary.Clear(); Using Clear() Method The Clear() method removes all key-value pairs from the HybridDictionary and sets the Count property to zero − Example using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() ...

Read More

Get an enumerator that iterates through the Hashtable in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 422 Views

To get an enumerator that iterates through the Hashtable in C#, you use the GetEnumerator() method. This method returns an IDictionaryEnumerator that provides key-value pair access to the hashtable elements. Syntax Following is the syntax for getting an enumerator from a Hashtable − IDictionaryEnumerator enumerator = hashtable.GetEnumerator(); The enumerator provides the following key members − enumerator.MoveNext() // advances to next element, returns bool enumerator.Key // gets current key enumerator.Value // gets current value enumerator.Entry ...

Read More

Get the minimum value in the SortedSet in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 188 Views

The SortedSet class in C# provides built-in properties to efficiently retrieve the minimum and maximum values. The Min property returns the smallest element, while the Max property returns the largest element in the sorted collection. Since SortedSet maintains elements in sorted order, accessing the minimum and maximum values is an O(1) operation, making it very efficient for scenarios where you frequently need these extreme values. Syntax Following is the syntax to get the minimum value from a SortedSet − T minValue = sortedSet.Min; Following is the syntax to get the maximum value from ...

Read More
Showing 7101–7110 of 21,090 articles
« Prev 1 709 710 711 712 713 2109 Next »
Advertisements