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 184 of 840
Get the number of key/value pairs in the StringDictionary in C#
The StringDictionary class in C# provides the Count property to get the number of key/value pairs stored in the dictionary. This property is useful for determining the size of the collection and performing operations based on the dictionary's length. Syntax Following is the syntax to get the count of key/value pairs in a StringDictionary − int count = stringDictionary.Count; Return Value The Count property returns an integer representing the number of key/value pairs currently stored in the StringDictionary. Using Count Property with Basic StringDictionary Example using System; using System.Collections; ...
Read MoreHow to change the CursorSize of the Console in C#?
The Console.CursorSize property in C# allows you to change the size of the cursor in the console window. The cursor size is specified as a percentage of the character cell height, ranging from 1 to 100. Syntax Following is the syntax for setting the cursor size − Console.CursorSize = value; Parameters value − An integer between 1 and 100, representing the cursor size as a percentage of the character cell height. Using Console.CursorSize Property The cursor size can be set to different values to make it more ...
Read MoreC# BitConverter.ToChar() Method
The BitConverter.ToChar() method in C# converts two consecutive bytes from a byte array into a Unicode character. This method reads two bytes starting at a specified position and interprets them as a 16-bit Unicode character using little-endian byte order. Syntax public static char ToChar(byte[] value, int startIndex); Parameters value − The byte array containing the bytes to convert. startIndex − The starting position within the byte array. Two consecutive bytes are read from this position. Return Value Returns a char value formed by combining two bytes ...
Read MoreRemoving the node at the start of the LinkedList in C#
The LinkedList class in C# provides the RemoveFirst() method to remove the node at the start of the linked list. This method removes the first node and automatically updates the list's internal structure and count. Syntax Following is the syntax for removing the first node from a LinkedList − linkedList.RemoveFirst(); The method throws an InvalidOperationException if the LinkedList is empty. RemoveFirst() Operation One Two Three Four ...
Read MoreDifference Between dispose() and finalize() in C#
In this article, we will understand the difference between the Dispose() and Finalize() methods in C#. Both methods are used for resource cleanup, but they serve different purposes and are invoked in different ways during the object lifecycle. The Dispose() method provides deterministic cleanup where you control exactly when resources are freed, while Finalize() provides a safety net for cleanup that runs during garbage collection. Syntax Following is the syntax for implementing Dispose() method − public class MyClass : IDisposable { public void Dispose() { // ...
Read MoreSingle.Equals() Method in C# with Examples
The Single.Equals() method in C# is used to return a value indicating whether two instances of Single represent the same value. The Single type is an alias for float in C#, so this method compares floating-point values for equality. Syntax The Single.Equals() method has two overloads − public bool Equals(float obj); public override bool Equals(object obj); Parameters obj − The object or float value to compare with the current instance. Return Value Returns true if the specified value is equal to the current instance; otherwise, false. For the object overload, it ...
Read MoreGet an ICollection containing the keys in ListDictionary in C#
The ListDictionary class in C# provides a Keys property that returns an ICollection containing all the keys in the dictionary. This is useful when you need to iterate through or process only the keys without accessing their corresponding values. Syntax Following is the syntax to get the keys collection from a ListDictionary − ICollection keys = listDictionary.Keys; Return Value The Keys property returns an ICollection object that contains all the keys from the ListDictionary. The keys are returned in the same order as they were added to the dictionary. Using Keys Property ...
Read MoreC# BitConverter.ToString(Byte[]) Method
The BitConverter.ToString() method in C# converts an array of bytes to its hexadecimal string representation. Each byte is converted to a two-digit uppercase hexadecimal value, with hyphens separating each pair. Syntax Following is the syntax for the BitConverter.ToString() method − public static string ToString(byte[] value); Parameters value − An array of bytes to convert to hexadecimal string representation. Return Value Returns a string containing hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in the byte array. Byte Array to Hex ...
Read MoreGet an ICollection containing the values in HybridDictionary in C#
The HybridDictionary class in C# provides the Values property that returns an ICollection containing all the values in the dictionary. This collection can be used to iterate through values or copy them to an array for further processing. Syntax Following is the syntax to get the values collection from a HybridDictionary − ICollection values = hybridDictionary.Values; To copy values to an array − hybridDictionary.Values.CopyTo(array, startIndex); How It Works The Values property returns an ICollection that contains all the values stored in the HybridDictionary. The order of values may vary ...
Read MoreCheck whether a SortedList object contains a specific key in C#?
To check whether a SortedList object contains a specific key in C#, you use the Contains() method. This method returns true if the key exists in the SortedList, otherwise false. A SortedList automatically maintains its elements in sorted order by key. Syntax Following is the syntax for checking if a key exists in a SortedList − bool result = sortedList.Contains(key); Parameters key: The key to search for in the SortedList. The key can be of any type that implements IComparable. Return Value The Contains() method returns a bool value ...
Read More