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
Csharp Articles
Page 47 of 196
Only 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 MoreGet the number of key/values pairs contained in OrderedDictionary in C#
The OrderedDictionary class in C# provides a Count property to get the number of key-value pairs it contains. This property returns an integer value representing the total number of elements in the collection. OrderedDictionary is part of the System.Collections.Specialized namespace and maintains the insertion order of elements while allowing access by both key and index. Syntax Following is the syntax for accessing the Count property − int count = orderedDictionary.Count; Using Count Property with OrderedDictionary Example using System; using System.Collections; using System.Collections.Specialized; public class Demo { ...
Read MoreHow to get Fourth Element of the Tuple in C#?
To get the fourth element of a Tuple in C#, you use the Item4 property. This property provides direct access to the fourth item stored in the tuple, regardless of the tuple's total size. Syntax Following is the syntax for accessing the fourth element of a tuple − var fourthElement = tuple.Item4; The Item4 property returns the value stored at the fourth position in the tuple. Using Item4 with Different Tuple Types Example with 7-Tuple using System; public class Demo { public static void Main(String[] ...
Read MoreGetting the Largest Window Height and Width of the Console in C#
The Console class in C# provides properties to determine the maximum possible window dimensions for a console application. The LargestWindowHeight and LargestWindowWidth properties return the largest height and width that the console window can have on the current system. These properties are useful when you need to maximize the console window or ensure your application's display fits within the system's constraints. Syntax Following is the syntax for getting the largest window height − int maxHeight = Console.LargestWindowHeight; Following is the syntax for getting the largest window width − int maxWidth = ...
Read MoreChar Struct in C#
The Char struct in C# represents a single Unicode character as a UTF-16 code unit. It provides numerous static methods for character classification, conversion, and comparison operations. The Char struct is a value type that implements IComparable, IConvertible, and IEquatable interfaces. Key Char Methods Method Description ConvertToUtf32(Char, Char) Converts the value of a UTF-16 encoded surrogate pair into a Unicode code point. ConvertToUtf32(String, Int32) Converts the value of a UTF-16 encoded character or surrogate pair at a specified position in a string into a Unicode code point. ...
Read MoreConvert Class in C#
The Convert class in C# provides static methods to convert between different base data types. It offers type-safe conversion methods that can handle null values and format providers, making it more robust than direct casting for many scenarios. The Convert class includes methods like ToBoolean(), ToDouble(), ToDecimal(), ToInt32(), and many others, each designed to convert values to their respective target types while handling edge cases and cultural formatting. Convert.ToBoolean() Method The Convert.ToBoolean() method converts a specified value to an equivalent Boolean value − Syntax public static bool ToBoolean(string value, IFormatProvider provider); public static bool ...
Read MoreCheck the HybridDictionary for a specific key in C#
The HybridDictionary class in C# provides the Contains() method to check whether a specific key exists in the collection. This method returns true if the key is found, otherwise false. HybridDictionary is part of the System.Collections.Specialized namespace and automatically switches between a ListDictionary and Hashtable based on the number of entries for optimal performance. Syntax Following is the syntax for checking if a key exists in HybridDictionary − public virtual bool Contains(object key) Parameters The Contains() method accepts the following parameter − key − The key to locate in the HybridDictionary. ...
Read MoreCheck whether a Hashtable contains a specific key or not in C#
The Hashtable class in C# provides the Contains() method to check whether a specific key exists in the collection. This method returns true if the key is found, and false otherwise. Syntax Following is the syntax for checking if a Hashtable contains a specific key − bool result = hashtable.Contains(key); Parameters key − The key to search for in the Hashtable. This parameter is of type Object. Return Value The Contains() method returns a bool value − true if the Hashtable contains the specified ...
Read MoreCheck whether an element is contained in the ArrayList in C#
The ArrayList.Contains() method in C# checks whether a specific element exists in the ArrayList. This method returns a boolean value − true if the element is found, false otherwise. Syntax Following is the syntax for the Contains() method − public virtual bool Contains(object item) Parameters item − The object to locate in the ArrayList. The value can be null. Return Value Returns true if the item is found in the ArrayList; otherwise, false. Using Contains() with String Elements The following example demonstrates checking for string ...
Read MoreInsert a new entry in OrderedDictionary with specified key and value in C#
The OrderedDictionary class in C# provides the Insert method to add a new entry at a specific position while maintaining the order of existing elements. This method allows you to specify both the index position and the key-value pair to insert. Syntax Following is the syntax for inserting an entry at a specific position in an OrderedDictionary − orderedDictionary.Insert(index, key, value); Parameters index − The zero-based index at which to insert the key-value pair. key − The key of the entry to insert. value − The value ...
Read More