Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by AmitDiwan
Page 198 of 840
Check if HybridDictionary has fixed size in C#
The HybridDictionary class in C# is a specialized collection that combines the performance benefits of both ListDictionary and Hashtable. To check if a HybridDictionary has a fixed size, you can use the IsFixedSize property, which returns false for standard HybridDictionary instances since they are dynamically resizable. Syntax Following is the syntax for checking if a HybridDictionary has a fixed size − bool isFixed = hybridDictionary.IsFixedSize; HybridDictionary Properties The HybridDictionary class provides several properties to check its characteristics − IsFixedSize − Returns true if the dictionary has a fixed size; otherwise, false ...
Read MoreUInt32.CompareTo() Method in C# with Examples
The UInt32.CompareTo() method in C# is used to compare the current instance to a specified object or UInt32 and returns an indication of their relative values. This method is essential for sorting operations and determining the ordering relationship between unsigned 32-bit integers. Syntax The UInt32.CompareTo() method has two overloads − public int CompareTo(object value); public int CompareTo(uint value); Parameters value (object) − An object to compare, or null. value (uint) − An unsigned integer to compare. Return Value The method returns an int that indicates the relative order of ...
Read MoreGet the number of nodes contained in LinkedList in C#
In C#, the LinkedList class provides the Count property to get the number of nodes contained in the LinkedList. This property returns an integer representing the total number of elements in the collection. Syntax Following is the syntax to get the count of nodes in a LinkedList − int count = linkedList.Count; Return Value The Count property returns an int value representing the number of nodes currently present in the LinkedList. LinkedList Node Count Node A Node B ...
Read MoreReverse the order of the elements in the entire List or in the specified range in C#
The List.Reverse() method in C# allows you to reverse the order of elements in a List. You can reverse the entire list or reverse a specific range of elements within the list. Syntax Following is the syntax for reversing the entire list − list.Reverse(); Following is the syntax for reversing a specified range of elements − list.Reverse(int index, int count); Parameters index − The zero-based starting index of the range to reverse. count − The number of elements in the range to reverse. ...
Read MoreUInt32.Equals() Method in C# with Examples
The UInt32.Equals() method in C# returns a value indicating whether this instance is equal to a specified object or UInt32. This method provides two overloads for comparing 32-bit unsigned integers with different parameter types. Syntax Following are the two overloads of the UInt32.Equals() method − public override bool Equals (object obj); public bool Equals (uint value); Parameters obj − An object to compare with this instance (first overload). value − A 32-bit unsigned integer to compare with this instance (second overload). Return Value Both methods ...
Read MoreBoolean.GetTypeCode() Method in C# with Examples
The Boolean.GetTypeCode() method in C# is used to return the type code for the Boolean value type. This method returns TypeCode.Boolean, which is part of the TypeCode enumeration that represents different data types in the .NET framework. Syntax Following is the syntax for the Boolean.GetTypeCode() method − public TypeCode GetTypeCode(); Return Value This method returns TypeCode.Boolean, which represents the Boolean data type in the TypeCode enumeration. Using GetTypeCode() with Boolean Values Example using System; public class Demo { public static void Main(String[] args) { ...
Read MoreHow to change the WindowTop of the Console in C#?
The Console.WindowTop property in C# gets or sets the top position of the console window relative to the screen buffer. This property is useful when you need to programmatically control the console window's vertical position within the buffer area. Syntax Following is the syntax to get or set the WindowTop property − // Get the current WindowTop position int topPosition = Console.WindowTop; // Set the WindowTop position Console.WindowTop = value; Parameters The WindowTop property accepts an integer value representing the top row of the console window area within the screen buffer. The ...
Read MoreGetting an enumerator that iterates through HashSet in C#
A HashSet in C# is a collection that stores unique elements without duplicates. To iterate through a HashSet, you can use the GetEnumerator() method which returns an enumerator object, or use a foreach loop for simpler iteration. The HashSet.Enumerator provides manual control over iteration using MoveNext() and Current properties, while foreach handles enumeration automatically behind the scenes. Syntax Following is the syntax for getting an enumerator from a HashSet − HashSet.Enumerator enumerator = hashSet.GetEnumerator(); while (enumerator.MoveNext()) { T current = enumerator.Current; // use current element } ...
Read MoreCheck whether the Dictionary contains a specific value or not in C#
The Dictionary class in C# provides the ContainsValue() method to check whether a specific value exists in the dictionary. This method returns true if the value is found, otherwise false. Syntax Following is the syntax for the ContainsValue() method − public bool ContainsValue(TValue value); Parameters value − The value to locate in the Dictionary. Return Value Returns true if the Dictionary contains an element with the specified value; otherwise, false. Using ContainsValue() - Value Found The following example demonstrates checking for an existing value in ...
Read MoreSortedDictionary.Values Property in C#
The SortedDictionary.Values property in C# is used to get a collection containing the values in the SortedDictionary. This property returns a ValueCollection that preserves the sorted order of the original dictionary based on the keys. Syntax Following is the syntax for the Values property − public SortedDictionary.ValueCollection Values { get; } Return Value The property returns a SortedDictionary.ValueCollection containing all the values in the sorted dictionary. The values maintain the same order as their corresponding keys in the sorted dictionary. Using Values Property to Iterate Through Values The following example demonstrates ...
Read More