AmitDiwan

AmitDiwan

8,392 Articles Published

Articles by AmitDiwan

Page 182 of 840

Getting the index of the specified key in a SortedList object in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 340 Views

To get the index of a specified key in a SortedList object, use the IndexOfKey() method. This method returns the zero-based index of the key within the sorted collection, or -1 if the key is not found. Syntax Following is the syntax for the IndexOfKey() method − public virtual int IndexOfKey(object key) Parameters key − The key to locate in the SortedList object. Return Value Returns the zero-based index of the key parameter if found; otherwise, returns -1. Example The following example demonstrates how to find the ...

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

Getting the key at the specified index of a SortedList object in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 158 Views

The SortedList class in C# maintains its elements in sorted order by key. To get the key at a specified index, use the GetKey() method. Since SortedList automatically sorts elements alphabetically by key, the index positions correspond to the sorted order, not the insertion order. Syntax Following is the syntax for getting a key at the specified index − public virtual object GetKey(int index) Parameters index − The zero-based index of the key to get. Return Value Returns the key at the specified index of the SortedList ...

Read More

Get the specified members of the current Type in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 153 Views

To get the specified members of the current Type in C#, we use the GetMember() method from the System.Reflection namespace. This method allows us to retrieve information about specific members of a type, such as fields, properties, methods, and events. Syntax Following is the syntax for getting specified members of a Type − Type.GetMember(string name) Type.GetMember(string name, BindingFlags bindingAttr) Type.GetMember(string name, MemberTypes type, BindingFlags bindingAttr) Parameters name − The string containing the name of the member to get. bindingAttr − A bitmask comprised of one or more BindingFlags that ...

Read More

MathF.Asinh() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 154 Views

The MathF.Asinh() method in C# returns the inverse hyperbolic sine (arc hyperbolic sine) of a specified single-precision floating-point number. This method is part of the System namespace and is commonly used in mathematical calculations involving hyperbolic functions. The inverse hyperbolic sine function is the inverse of the hyperbolic sine function. For any real number x, Asinh(x) returns the value y such that sinh(y) = x. Syntax Following is the syntax for the MathF.Asinh() method − public static float Asinh(float val); Parameters val − A single-precision floating-point number representing the hyperbolic sine ...

Read More

Add element to SortedSet in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 236 Views

The SortedSet class in C# provides a way to store unique elements in sorted order. To add elements to a SortedSet, you use the Add() method, which automatically maintains the sorted order and prevents duplicate entries. Syntax Following is the syntax for adding elements to a SortedSet − SortedSet sortedSet = new SortedSet(); bool added = sortedSet.Add(element); Parameters element − The element to add to the SortedSet. Return Value The Add() method returns a bool value: true − If the element was successfully added (not a duplicate). false ...

Read More

MathF.Atan() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 150 Views

The MathF.Atan() method in C# is used to return the angle whose tangent is given as a float value argument. This method returns the arctangent (inverse tangent) of the specified number, with the result expressed in radians between -π/2 and π/2. Syntax Following is the syntax for the MathF.Atan() method − public static float Atan (float val); Parameters val − A float representing a tangent value. This parameter can be any real number including positive infinity, negative infinity, or NaN (Not a Number). Return Value The method ...

Read More

Add key and value into OrderedDictionary collection in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 246 Views

The OrderedDictionary collection in C# maintains the insertion order of key-value pairs, combining features of both hashtables and arrays. To add key-value pairs, use the Add() method which accepts the key and value as parameters. OrderedDictionary is part of the System.Collections.Specialized namespace and allows access to elements both by key and by index, making it useful when you need to preserve insertion order. Syntax Following is the syntax for adding key-value pairs to an OrderedDictionary − OrderedDictionary dict = new OrderedDictionary(); dict.Add(key, value); Parameters key − The key of the element ...

Read More

How to get Synchronize access to the Stack in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 178 Views

In C#, the Stack class is not thread-safe by default. To achieve synchronized access to a Stack in a multithreaded environment, you can use the SyncRoot property with the lock statement. This ensures that only one thread can access the Stack at a time, preventing data corruption and race conditions. Syntax Following is the syntax for synchronizing access to a Stack − lock(stack.SyncRoot) { // Thread-safe operations on stack foreach(Object item in stack) { // Process items safely } } ...

Read More

Char.IsDigit() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 2K+ Views

The Char.IsDigit() method in C# determines whether a specified Unicode character is categorized as a decimal digit. This method is useful for validating input, parsing strings, and filtering numeric characters from text. Syntax Following is the syntax for the Char.IsDigit() method − public static bool IsDigit(char ch); Parameters ch − The Unicode character to evaluate. Return Value Returns true if the character is a decimal digit; otherwise, false. Using Char.IsDigit() with Different Characters Example 1 - Testing Non-Digit Characters using System; public ...

Read More
Showing 1811–1820 of 8,392 articles
« Prev 1 180 181 182 183 184 840 Next »
Advertisements