Programming Articles

Page 68 of 2547

Check if Hashtable is read-only in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 186 Views

The Hashtable class in C# provides the IsReadOnly property to determine whether the hashtable is read-only or allows modifications. A read-only hashtable prevents adding, removing, or modifying elements after creation. Syntax Following is the syntax for checking if a Hashtable is read-only − bool isReadOnly = hashtable.IsReadOnly; Return Value The IsReadOnly property returns a bool value − true if the Hashtable is read-only false if the Hashtable allows modifications Using IsReadOnly with Standard Hashtable A standard Hashtable created using the default constructor is not ...

Read More

How to enable Session in C# ASP.NET Core?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 18K+ Views

Session is a server-side storage feature in ASP.NET Core that enables you to store user data temporarily across multiple requests. Session data is stored in a dictionary on the server, with each user session identified by a unique SessionId. The SessionId is stored as a cookie on the client side and sent with every request to maintain the connection between the client and their session data. This cookie is browser-specific and cannot be shared between different browsers. While SessionId cookies persist only for the browser session, the actual session data on the server has a configurable timeout (default: 20 ...

Read More

Checking the Given Indexes are Equal or not in C#

Siva Sai
Siva Sai
Updated on 17-Mar-2026 587 Views

Indexes are a vital part of working with arrays and other data structures in C#. They help us navigate and manipulate data effectively. This article will guide you on how to check whether given indexes in a data structure are equal or not in C#. Understanding Indexes in C# In C#, an index represents a position in an array or collection. The index of the first element is 0, and it increases by one for each subsequent element. This is called zero-based indexing. Array Index Positions ...

Read More

Check if the Hashtable contains a specific Key in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 362 Views

To check if a Hashtable contains a specific key in C#, use the ContainsKey() method. This method returns true if the specified key exists in the Hashtable, and false otherwise. Syntax Following is the syntax for the ContainsKey() method − public virtual bool ContainsKey(object key) Parameters key − The key to locate in the Hashtable. Return Value Returns true if the Hashtable contains an element with the specified key; otherwise, false. Using ContainsKey() with String Keys Example using System; using System.Collections; public class Demo ...

Read More

Check if two SortedSet objects are equal in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 264 Views

In C#, checking if two SortedSet objects are equal involves understanding that SortedSet uses reference equality by default with the Equals() method. This means two sets are considered equal only if they reference the same object in memory, not if they contain the same elements. To properly check if two SortedSet objects contain the same elements, you need to use the SetEquals() method or implement custom comparison logic. Using Equals() Method (Reference Equality) The Equals() method checks if two SortedSet objects reference the same instance in memory − using System; using System.Collections.Generic; public class ...

Read More

Get an ICollection containing the keys in the Hashtable C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 202 Views

To get an ICollection containing the keys in the Hashtable, you can use the Keys property. The Hashtable.Keys property returns an ICollection object that contains all the keys from the hashtable, which can then be iterated through to access each key. Syntax Following is the syntax for accessing keys from a Hashtable − ICollection keys = hashtable.Keys; Return Value The Keys property returns an ICollection containing all the keys in the Hashtable. The order of keys is not guaranteed as Hashtable does not maintain insertion order. Hashtable Keys ...

Read More

Console.TreatControlCAsInput Property in C# with Examples

Siva Sai
Siva Sai
Updated on 17-Mar-2026 235 Views

The Console.TreatControlCAsInput property in C# is a Boolean property that determines whether the Ctrl+C key combination is treated as ordinary input or as an interruption signal handled by the operating system. By default, pressing Ctrl+C terminates a console application. However, setting this property to true allows the application to capture Ctrl+C as regular input, preventing automatic termination. Syntax Following is the syntax for setting and getting the Console.TreatControlCAsInput property − // Setting the property Console.TreatControlCAsInput = true; // or false // Getting the property value bool treatAsInput = Console.TreatControlCAsInput; Default Behavior ...

Read More

Check if the StringDictionary contains a specific key in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 195 Views

The StringDictionary class in C# provides the ContainsKey() method to check if a specific key exists in the dictionary. This method returns true if the key is found, otherwise false. Note that StringDictionary automatically converts keys to lowercase for storage and comparison. Syntax Following is the syntax for using the ContainsKey() method − bool ContainsKey(string key) Parameters key − The string key to search for in the StringDictionary. Return Value Returns true if the StringDictionary contains the specified key; otherwise, false. Using ContainsKey() Method Example ...

Read More

Convert a Character to the String in C#

Siva Sai
Siva Sai
Updated on 17-Mar-2026 833 Views

Character manipulation is a common task in many programming applications. This article will guide you through the process of converting a character to a string in C#, an essential operation in various programming scenarios such as data parsing, formatting, and string building operations. Understanding Characters and Strings in C# Before we dive into the conversion process, let's first understand what characters and strings are in C#. A character (char) represents a single Unicode character and is denoted inside single quotes, while a string is a sequence of characters enclosed in double quotes. Character ...

Read More

Check if the StringDictionary contains a specific value in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 183 Views

The StringDictionary class in C# provides the ContainsValue() method to check if a specific value exists in the dictionary. This method returns true if the value is found, otherwise false. Note that StringDictionary automatically converts all keys to lowercase, but values remain case-sensitive. Syntax Following is the syntax for checking if a StringDictionary contains a specific value − public virtual bool ContainsValue(string value) Parameters value − The string value to locate in the StringDictionary. The value can be null. Return Value Returns true if the StringDictionary contains an element ...

Read More
Showing 671–680 of 25,467 articles
« Prev 1 66 67 68 69 70 2547 Next »
Advertisements