Programming Articles

Page 69 of 2547

Gets an ICollection containing the values in the Hashtable in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 142 Views

The Hashtable.Values property in C# returns an ICollection containing all the values in the Hashtable. This allows you to iterate through or manipulate the values without accessing the keys directly. Syntax Following is the syntax to get the values collection from a Hashtable − public virtual ICollection Values { get; } Return Value The Values property returns an ICollection containing all the values in the Hashtable. The order of values is not guaranteed since Hashtable does not maintain insertion order. Using Hashtable.Values Property Example using System; using System.Collections; ...

Read More

Get a collection of keys in the StringDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 178 Views

The StringDictionary class in C# provides the Keys property to retrieve a collection of all keys in the dictionary. This property returns an ICollection containing all the keys, which can be copied to an array or iterated through directly. Syntax Following is the syntax for accessing the Keys property − StringDictionary dictionary = new StringDictionary(); ICollection keys = dictionary.Keys; To copy keys to an array − string[] keyArray = new string[dictionary.Count]; dictionary.Keys.CopyTo(keyArray, 0); Using Keys Property The following example demonstrates how to retrieve and display all keys from a ...

Read More

How can we inject the service dependency into the controller C# Asp.net Core?

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

ASP.NET Core uses a built-in Inversion of Control (IoC) container to inject dependencies into controllers and other services. This container, represented by the IServiceProvider implementation, supports constructor injection by default and manages application services throughout their lifecycle. To use dependency injection in controllers, you must first register your services with the IoC container in the ConfigureServices method of the Startup class or Program.cs file. Syntax Following is the syntax for registering services in the IoC container − services.AddSingleton(); services.AddScoped(); services.AddTransient(); Following is the syntax for constructor injection in a controller − ...

Read More

Check if two BitArray objects are equal in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 414 Views

The BitArray class in C# provides a compact way to store and manipulate arrays of bits. However, checking equality between two BitArray objects requires understanding how the Equals()

Read More

Gets or sets the element at the specified index in StringCollection in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 137 Views

The StringCollection class in C# provides an indexer property that allows you to get or set elements at a specified index. This indexer uses square bracket notation and provides direct access to collection elements by their zero-based index position. Syntax Following is the syntax for accessing elements by index in StringCollection − // Getting an element string element = stringCollection[index]; // Setting an element stringCollection[index] = "new value"; Parameters index − The zero-based index of the element to get or set. Return Value Returns the string ...

Read More

How to specify service lifetime for register service that added as a dependency C# Asp.net Core?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 698 Views

The built-in IoC container in ASP.NET Core manages the lifetime of registered services and automatically disposes service instances based on the specified lifetime. Understanding service lifetimes is crucial for proper dependency injection and resource management. The built-in IoC container supports three kinds of lifetimes − Singleton − IoC container will create and share a single instance of a service throughout the application's lifetime. Transient − The IoC container will create a new instance of the specified service type every time you ask for it. Scoped − IoC container will create an instance of the specified service type ...

Read More

How C# ASP.NET Core Middleware is different from HttpModule?

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

In ASP.NET Core, middleware replaces the traditional HttpModules used in classic ASP.NET. While both serve as components that handle HTTP requests and responses, they differ significantly in configuration, execution control, and architecture. Key Differences Overview HttpModules are event-driven components tied to the ASP.NET application lifecycle, while middleware components form a pipeline where each component can handle requests before passing them to the next component in the chain. HttpModules vs Middleware Architecture HttpModules (Classic ASP.NET) Event-driven execution Fixed lifecycle ...

Read More

Check if a Hashtable is equal to another Hashtable in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 265 Views

Checking if a Hashtable is equal to another Hashtable in C# can be done using the Equals() method. However, it's important to understand that this method performs reference equality checking by default, not content comparison. Syntax Following is the syntax to check Hashtable equality − bool result = hashtable1.Equals(hashtable2); Using Equals() Method for Reference Comparison The Equals() method checks if two Hashtables are the same reference, not if they contain the same key-value pairs − using System; using System.Collections; public class Demo { public static void Main() ...

Read More

What is Kestral C# Asp.net Core?

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

Kestrel is a cross-platform web server for ASP.NET Core. It is included by default in ASP.NET Core applications and is supported on all platforms where .NET Core runs. Kestrel serves as the primary HTTP server for ASP.NET Core applications and can be configured to work either as a standalone edge server or in combination with reverse proxy servers like IIS, Nginx, or Apache. Key Features Cross-platform: Runs on Windows, macOS, and Linux. Lightweight: Minimal overhead and high performance. HTTP/HTTPS support: Handles both HTTP and HTTPS protocols. Async/await support: Built ...

Read More

Converting a String to its Equivalent Byte Array in C#

Siva Sai
Siva Sai
Updated on 17-Mar-2026 2K+ Views

String manipulation is a common task in C# programming. In certain cases, you might need to convert a string into its equivalent byte array, such as when dealing with encryption, file I/O, or network communication. This article will walk you through the process of converting a string to a byte array in C#, illustrating the power and flexibility of C# in handling various data types. Understanding Strings and Byte Arrays in C# Before diving into the conversion process, let's understand what strings and byte arrays are in C#. In C#, a string is a sequence of characters, while ...

Read More
Showing 681–690 of 25,467 articles
« Prev 1 67 68 69 70 71 2547 Next »
Advertisements