AmitDiwan

AmitDiwan

8,392 Articles Published

Articles by AmitDiwan

Page 195 of 840

How to change the CursorTop of the Console in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 282 Views

The Console.CursorTop property in C# gets or sets the row position of the cursor within the console window. This property allows you to control the vertical position where text will be displayed, enabling you to create formatted console output, menus, or position text at specific locations. Syntax Following is the syntax for using Console.CursorTop − // Get current cursor top position int currentTop = Console.CursorTop; // Set cursor top position Console.CursorTop = value; Parameters The Console.CursorTop property accepts an integer value representing the row position (0-based) where the cursor should be positioned. ...

Read More

SByte.ToString() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 487 Views

The SByte.ToString() method in C# is used to convert the numeric value of a signed byte to its equivalent string representation. The sbyte data type represents 8-bit signed integers with values ranging from -128 to 127. Syntax Following is the syntax for the basic ToString() method − public override string ToString(); Following is the syntax for ToString() with format provider − public string ToString(IFormatProvider provider); public string ToString(string format); public string ToString(string format, IFormatProvider provider); Return Value The method returns a string that represents the value of the current ...

Read More

Add key and value into StringDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 290 Views

The StringDictionary class in C# provides a specialized collection for storing string key-value pairs. It is case-insensitive, meaning keys are automatically converted to lowercase when added. The Add() method is used to insert new key-value pairs into the collection. Syntax Following is the syntax for adding key-value pairs to a StringDictionary − StringDictionary dictionary = new StringDictionary(); dictionary.Add(key, value); Parameters key − The key to add to the StringDictionary (string type). value − The value associated with the key (string type). Key Rules ...

Read More

Get the number of key/value pairs in the Dictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 668 Views

The Dictionary class in C# provides the Count property to get the number of key/value pairs stored in the dictionary. This property returns an integer representing the total count of elements currently in the dictionary. Syntax Following is the syntax for using the Count property − Dictionary dictionary = new Dictionary(); int count = dictionary.Count; Parameters The Count property does not take any parameters. It is a read-only property that returns the current number of key/value pairs in the dictionary. Return Value The Count property returns an int value representing the ...

Read More

SortedDictionary.Keys Property in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 321 Views

The SortedDictionary.Keys property in C# returns a collection containing all the keys in the SortedDictionary. The keys are returned in sorted order based on the comparer used by the SortedDictionary. Syntax Following is the syntax for the Keys property − public SortedDictionary.KeyCollection Keys { get; } Return Value The Keys property returns a SortedDictionary.KeyCollection containing all the keys in the SortedDictionary. The collection is read-only and reflects changes made to the underlying dictionary. Using Keys Property with Integer Keys Example using System; using System.Collections.Generic; public class Demo { ...

Read More

Getting the keys in a SortedList object C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 135 Views

The SortedList class in C# stores key-value pairs sorted by the keys. To retrieve all the keys from a SortedList object, you use the Keys property, which returns an ICollection containing all the keys in sorted order. Syntax Following is the syntax for getting keys from a SortedList − SortedList sortedList = new SortedList(); ICollection keys = sortedList.Keys; The Keys property returns an ICollection that can be iterated using a foreach loop − foreach(string key in keys) { Console.WriteLine(key); } Using Keys Property with String Keys ...

Read More

ConvertDecimal to equivalent 32-bit unsigned integer in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 524 Views

To convert the value of the specified decimal to the equivalent 32-bit unsigned integer, C# provides the Decimal.ToUInt32() method. This method truncates the fractional part and returns only the whole number portion as a uint value. Syntax Following is the syntax for converting decimal to uint − public static uint ToUInt32(decimal value); Parameters value − The decimal number to be converted to a 32-bit unsigned integer. Return Value Returns a 32-bit unsigned integer (uint) equivalent to the specified decimal value. The fractional part is truncated, not rounded. Using ...

Read More

MathF.Min() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 154 Views

The MathF.Min() method in C# returns the smaller of two specified float values. This method is part of the MathF class, which provides mathematical functions optimized for single-precision floating-point numbers. Syntax Following is the syntax − public static float Min(float val1, float val2); Parameters val1 − The first float number to compare. val2 − The second float number to compare. Return Value Returns a float value representing the smaller of the two input parameters. If either value is NaN (Not a Number), the method returns ...

Read More

SortedDictionary.Remove() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 185 Views

The SortedDictionary.Remove() method in C# is used to remove the element with the specified key from the SortedDictionary. This method returns a bool value indicating whether the removal was successful. Syntax Following is the syntax for the Remove() method − public bool Remove (TKey key); Parameters key − The key of the element to remove from the SortedDictionary. Return Value The method returns true if the element is successfully found and removed; otherwise, false. This method also returns false if the key is not found in the original SortedDictionary. ...

Read More

Check if a SortedList is read-only in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 142 Views

The SortedList class in C# provides the IsReadOnly property to determine whether the collection can be modified. A read-only SortedList cannot have elements added, removed, or modified after creation. Syntax Following is the syntax to check if a SortedList is read-only − bool isReadOnly = sortedList.IsReadOnly; Return Value The IsReadOnly property returns a bool value − true if the SortedList is read-only false if the SortedList allows modifications Example The following example demonstrates how to check if a SortedList is read-only − ...

Read More
Showing 1941–1950 of 8,392 articles
« Prev 1 193 194 195 196 197 840 Next »
Advertisements