Csharp Articles

Page 47 of 196

Only return fields which appear a certain number of times using MySQL DISTINCT?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 130 Views

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 More

Get the number of key/values pairs contained in OrderedDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 150 Views

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 More

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

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 140 Views

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 More

Getting the Largest Window Height and Width of the Console in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 290 Views

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 More

Char Struct in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 463 Views

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 More

Convert Class in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 801 Views

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 More

Check the HybridDictionary for a specific key in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 171 Views

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 More

Check whether a Hashtable contains a specific key or not in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 206 Views

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 More

Check whether an element is contained in the ArrayList in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 243 Views

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 More

Insert a new entry in OrderedDictionary with specified key and value in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 181 Views

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
Showing 461–470 of 1,951 articles
« Prev 1 45 46 47 48 49 196 Next »
Advertisements