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
Programming Articles
Page 93 of 2547
Remove the entry at specified index from OrderedDictionary in C#
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 MoreHow to rotate an array k time using C#?
Array rotation is a common programming problem where elements are shifted by k positions. When we rotate an array to the right by k positions, the last k elements move to the beginning, and the remaining elements shift right. For example, if we have array [1, 2, 3, 4, 5] and rotate it right by 2 positions, we get [4, 5, 1, 2, 3]. Algorithm The most efficient approach uses the reversal algorithm which works in three steps − Reverse the entire array Reverse the first k elements Reverse the remaining elements from position k ...
Read MoreRemove the entry with specified key from ListDictionary in C#
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 MoreCheck if HybridDictionary is Synchronized in C#
The HybridDictionary class in C# provides the IsSynchronized property to check if the dictionary is thread-safe for multi-threaded operations. By default, HybridDictionary is not synchronized, meaning it is not thread-safe. A HybridDictionary automatically switches between a ListDictionary (for small collections) and a Hashtable (for larger collections) based on the number of elements, but remains unsynchronized unless explicitly wrapped. Syntax The IsSynchronized property returns a boolean value indicating thread safety − bool isSync = hybridDictionary.IsSynchronized; To create a synchronized wrapper around a HybridDictionary − HybridDictionary syncDict = (HybridDictionary)HybridDictionary.Synchronized(originalDict); Using IsSynchronized ...
Read MoreChar.IsSeparator () Method in C#
The Char.IsSeparator() method in C# indicates whether the specified Unicode character is categorized as a separator character. This method checks if the character belongs to the separator category in Unicode, which includes space characters, line separators, and paragraph separators. Syntax Following is the syntax − public static bool IsSeparator(char ch); Parameters ch − The Unicode character to evaluate. Return Value Returns true if the character is categorized as a separator; otherwise, false. Types of Separator Characters The Unicode separator category includes three subcategories − Space Separator ...
Read MoreCheck if the specified string is in the StringCollection in C#
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 MoreOnly return fields which appear a certain number of times using MySQL DISTINCT?
To return fields appearing a certain number of times using MySQL DISTINCT, you combine GROUP BY, HAVING, and COUNT() functions. The DISTINCT keyword ensures unique groupings, while HAVING filters groups based on their count. Syntax Following is the syntax for returning fields that appear a specific number of times − SELECT DISTINCT columnName, COUNT(columnName) FROM tableName WHERE columnName LIKE 'pattern%' GROUP BY columnName HAVING COUNT(*) > threshold ORDER BY columnName; Key Components DISTINCT − Ensures unique groupings of the column values COUNT() − Counts occurrences of each grouped value GROUP BY − ...
Read MoreCount the total number of elements in the List in C#?
To count the total number of elements in a List in C#, you use the Count property. This property returns an integer value representing the current number of elements stored in the list. Syntax Following is the syntax for using the Count property − List list = new List(); int count = list.Count; Return Value The Count property returns an int value representing the number of elements currently in the list. It returns 0 for an empty list. Using Count Property with List Operations Example using System; using System.Collections.Generic; ...
Read MoreCheck if the StringCollection is read-only in C#
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 MoreRemove the first occurrence from the StringCollection in C#
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