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 193 of 840
Console.SetBufferSize() Method in C#
The Console.SetBufferSize() method in C# sets the height and width of the console screen buffer area to the specified values. The buffer size determines how much text the console can hold in memory, which affects scrolling and display capabilities. Syntax Following is the syntax for the Console.SetBufferSize() method − public static void SetBufferSize(int width, int height); Parameters width − The width of the buffer area measured in columns. height − The height of the buffer area measured in rows. The buffer size must be greater than ...
Read MoreSortedDictionary.Count Property in C#
The SortedDictionary.Count property in C# returns the number of key/value pairs contained in the SortedDictionary. This read-only property is useful for determining the size of the collection and checking if it's empty. Syntax Following is the syntax for the Count property − public int Count { get; } Return Value The Count property returns an int value representing the total number of key/value pairs in the SortedDictionary. It returns 0 if the dictionary is empty. SortedDictionary Count Property Key-Value Pairs: {100: ...
Read MoreSortedDictionary.Item[] Property in C#
The SortedDictionary.Item[] property in C# provides indexer access to get or set values associated with specified keys in a sorted dictionary. This property allows you to access dictionary elements using square bracket notation, making it convenient to retrieve and modify values. Syntax Following is the syntax for the SortedDictionary.Item[] property − public TValue this[TKey key] { get; set; } Parameters key − The key of the value to get or set of type TKey. Return Value Returns the value of type TValue associated with the specified key. ...
Read MoreGetting the Type of the Tuple's Element in C#
In C#, you can get the type of a tuple or its individual elements using the GetType() method and reflection. The GetType() method returns the runtime type of the tuple, which includes information about all its element types. Syntax Following is the syntax to get the type of a tuple − var tuple = Tuple.Create(value1, value2, ...); Type tupleType = tuple.GetType(); To get the type of individual elements, you can use the typeof operator or access element types through reflection − Type elementType = typeof(T); // where T is the element type ...
Read MoreGet an enumerator that iterates through the StringDictionary in C#
The StringDictionary class in C# provides the GetEnumerator() method to obtain an enumerator that iterates through the collection. This enumerator returns DictionaryEntry objects containing key-value pairs. Note that StringDictionary automatically converts all keys to lowercase during storage. Syntax Following is the syntax for getting an enumerator from StringDictionary − IEnumerator enumerator = stringDictionary.GetEnumerator(); To iterate through the enumerator − while (enumerator.MoveNext()) { DictionaryEntry entry = (DictionaryEntry)enumerator.Current; // Use entry.Key and entry.Value } Using GetEnumerator() Method The following example demonstrates how to ...
Read MoreTotal number of elements in a specified dimension of an Array in C#
In C#, you can get the total number of elements in a specific dimension of an array using the GetLongLength() method. This method returns a long value representing the number of elements in the specified dimension, making it useful for both single-dimensional and multi-dimensional arrays. Syntax Following is the syntax for using GetLongLength() method − long count = array.GetLongLength(dimension); Parameters dimension − An integer that specifies the dimension (zero-based index) for which you want to get the number of elements. Return Value The method returns a long value representing ...
Read MoreUri.IsHexDigit() Method in C#
The Uri.IsHexDigit() method in C# determines whether a specified character is a valid hexadecimal digit. This method returns true if the character is a valid hexadecimal digit (0-9, A-F, a-f), and false otherwise. This method is commonly used when working with URL encoding, parsing hexadecimal values, or validating user input that should contain only hexadecimal characters. Syntax Following is the syntax − public static bool IsHexDigit(char ch); Parameters ch − The character to validate as a hexadecimal digit. Return Value Returns true if the character is ...
Read MoreSingle.ToString Method in C#
The Single.ToString() method in C# converts a float (single-precision floating-point) value to its string representation. This method is essential for displaying numeric values as text or preparing them for output operations. Syntax Following is the syntax for the parameterless ToString() method − public override string ToString(); The method can also accept format parameters − public string ToString(string format); public string ToString(IFormatProvider provider); public string ToString(string format, IFormatProvider provider); Return Value The method returns a string representation of the float value. Special values like infinity and NaN have specific string ...
Read MoreGetting the unique identifier for the current managed thread in C#
To get the unique identifier for the currently managed thread in C#, you can use the Thread.CurrentThread.ManagedThreadId property. This property returns an integer that uniquely identifies each managed thread within the application domain. The ManagedThreadId is different from the operating system thread ID and is specifically designed for managed code debugging and logging purposes. Syntax Following is the syntax for getting the managed thread ID − int threadId = Thread.CurrentThread.ManagedThreadId; For a specific thread object − Thread thread = new Thread(methodName); int threadId = thread.ManagedThreadId; Using ManagedThreadId with Regular ...
Read MoreHow to use strings in switch statement in C#
A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case. In C#, you can use strings directly in switch statements, making it convenient to handle text-based conditions. Syntax Following is the syntax for using strings in a switch statement − switch (stringVariable) { case "value1": // code block break; case "value2": ...
Read More