AmitDiwan

AmitDiwan

8,392 Articles Published

Articles by AmitDiwan

Page 199 of 840

Check if ListDictionary contains a specific key in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 176 Views

The ListDictionary class in C# provides the Contains() method to check if a specific key exists in the collection. This method returns true if the key is found, otherwise false. ListDictionary is part of the System.Collections.Specialized namespace and is optimized for small collections. Syntax Following is the syntax for using the Contains() − public bool Contains(object key); Parameters key − The object to locate in the ListDictionary. Return Value Returns true if the ListDictionary contains an element with the specified key; otherwise, false. Using Contains() Method ...

Read More

Get the TypeCode for value type UInt64 in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 202 Views

The GetTypeCode() method in C# returns a TypeCode enumeration value that identifies the specific type of a variable. For UInt64 (unsigned 64-bit integer) values, this method always returns TypeCode.UInt64, regardless of the actual numeric value stored. Syntax Following is the syntax for getting the TypeCode of a UInt64 value − TypeCode typeCode = uintValue.GetTypeCode(); Return Value The method returns TypeCode.UInt64 for all ulong variables, which represents the 64-bit unsigned integer type in the .NET type system. Using GetTypeCode() with UInt64 Values Example using System; public class Demo { ...

Read More

Random.Next() Method in C#

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

The Random.Next() method in C# is used to generate non-negative random integers. It provides multiple overloads to control the range of generated numbers, making it useful for various scenarios like games, simulations, and testing. Syntax The Random.Next() method has three overloads − public virtual int Next(); public virtual int Next(int maxValue); public virtual int Next(int minValue, int maxValue); Parameters maxValue − The exclusive upper bound of the random number (0 to maxValue-1). minValue − The inclusive lower bound of the random number. maxValue − The exclusive upper bound of the random number ...

Read More

Check if ListDictionary has a fixed size in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 261 Views

The ListDictionary class in C# provides the IsFixedSize property to determine whether the dictionary has a fixed size. A ListDictionary is a lightweight collection that stores key-value pairs using a singly linked list implementation, making it ideal for small collections (typically 10 or fewer items). Syntax Following is the syntax for checking if a ListDictionary has a fixed size − bool isFixed = listDictionary.IsFixedSize; Return Value The IsFixedSize property returns a bool value − true − The ListDictionary has a fixed size and cannot grow or shrink false ...

Read More

Uri.HexEscape(Char) Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 209 Views

The Uri.HexEscape() method in C# converts a specified character into its hexadecimal equivalent representation using percent-encoding. This method is particularly useful for URL encoding where certain characters need to be represented in hexadecimal format for safe transmission in URIs. Syntax Following is the syntax − public static string HexEscape(char ch); Parameters ch − The character to convert to hexadecimal representation. Return Value Returns a string containing the hexadecimal representation of the character in the format %XX, where XX is the two-digit hexadecimal value. HexEscape Character Conversion ...

Read More

Check if StringDictionary is synchronized in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 182 Views

The StringDictionary class in C# provides the IsSynchronized property to check whether the dictionary is synchronized (thread-safe). By default, StringDictionary is not synchronized, meaning it's not safe for concurrent access from multiple threads without external synchronization. Syntax Following is the syntax to check if a StringDictionary is synchronized − bool isSynchronized = stringDictionary.IsSynchronized; Properties IsSynchronized − Returns true if the StringDictionary is synchronized; otherwise, false. SyncRoot − Gets an object that can be used to synchronize access to the StringDictionary. Example 1: Basic Synchronization Check using System; using ...

Read More

Get all the interfaces implemented or inherited by the current Type in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 611 Views

The Type class in C# provides methods to retrieve all interfaces implemented or inherited by a specific type. The GetInterfaces() method returns an array of all interfaces, while GetInterface() method retrieves a specific interface by name. Syntax Following is the syntax for getting all interfaces implemented by a type − Type[] interfaces = type.GetInterfaces(); Following is the syntax for getting a specific interface by name − Type specificInterface = type.GetInterface("InterfaceName", ignoreCase); Parameters GetInterface(string name) − Returns the interface with the specified name. GetInterface(string name, bool ignoreCase) − Returns ...

Read More

Check if ArrayList is Synchronized (thread safe) in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 371 Views

The IsSynchronized property in C# is used to check if an ArrayList is synchronized (thread-safe). By default, ArrayList is not synchronized, meaning it's not safe for concurrent access by multiple threads. However, you can create a synchronized wrapper using the ArrayList.Synchronized() method. Syntax To check if an ArrayList is synchronized − bool isSync = arrayList.IsSynchronized; To create a synchronized ArrayList wrapper − ArrayList syncList = ArrayList.Synchronized(originalList); Return Value The IsSynchronized property returns a bool value: true if the ArrayList is synchronized (thread-safe) false if the ArrayList is ...

Read More

Get the TypeCode for value type UInt32 in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 172 Views

To get the TypeCode for value type UInt32 in C#, you can use the GetTypeCode() method. This method returns a TypeCode enumeration value that represents the data type of the current object. The UInt32 data type represents a 32-bit unsigned integer with values ranging from 0 to 4, 294, 967, 295. When you call GetTypeCode() on any uint variable, it returns TypeCode.UInt32. Syntax Following is the syntax for getting the TypeCode of a UInt32 value − TypeCode typeCode = uintVariable.GetTypeCode(); Return Value The GetTypeCode() method returns TypeCode.UInt32 for all uint variables, regardless ...

Read More

Insert an element into the ArrayList at the specified index in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 376 Views

The ArrayList.Insert() method in C# allows you to insert an element at a specific index position in an ArrayList. This method shifts all existing elements from the specified index to the right, making room for the new element. Syntax Following is the syntax for the Insert() method − arrayList.Insert(index, value); Parameters index − The zero-based index at which the new element should be inserted. value − The object to insert into the ArrayList. ArrayList Insert Operation ...

Read More
Showing 1981–1990 of 8,392 articles
« Prev 1 197 198 199 200 201 840 Next »
Advertisements