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

AmitDiwan
Updated on 17-Mar-2026 07:04:36

148 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
Updated on 17-Mar-2026 07:04:36

715 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
Updated on 17-Mar-2026 07:04:36

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

How to open a browser window in full screen using Selenium WebDriver with C#?

Debomita Bhattacharjee
Updated on 17-Mar-2026 07:04:36

2K+ Views

We can open a browser window in full screen using Selenium WebDriver in C# by using the Maximize() method. This method is applied on the WebDriver object through the window management interface and expands the browser to fill the entire screen. Syntax Following is the syntax for maximizing a browser window − driver.Manage().Window.Maximize(); For setting specific window size, you can also use − driver.Manage().Window.Size = new Size(width, height); Using Maximize() Method The Maximize() method is the most common approach to open a browser in full screen mode. It automatically ... Read More

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

AmitDiwan
Updated on 17-Mar-2026 07:04:36

278 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
Updated on 17-Mar-2026 07:04:36

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
Updated on 17-Mar-2026 07:04:36

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

Remove all odd numbers from an array in C#

AYUSH MISHRA
Updated on 17-Mar-2026 07:04:36

4K+ Views

Natural numbers are a set of positive integers, which are commonly used for counting and ordering. They begin from 1 and continue infinitely. In some contexts, it may also include 0. Here, we are going to learn about different approaches to removing all odd numbers from a given array using C#. Problem Description We are given an array, and we need to remove all the odd numbers from it. The resulting array should only contain even numbers. Example 1 Input: array = {1, 2, 3, 4, 5, 6} Output: {2, 4, 6} Explanation: ... Read More

Get an ICollection containing the values in OrderedDictionary in C#

AmitDiwan
Updated on 17-Mar-2026 07:04:36

598 Views

The OrderedDictionary class in C# provides a Values property that returns an ICollection containing all the values in the dictionary. This collection maintains the same insertion order as the original dictionary, making it useful when you need to work with dictionary values while preserving their order. Syntax Following is the syntax to access the Values property − ICollection values = orderedDictionary.Values; You can then iterate through the values or copy them to an array − string[] valueArray = new string[orderedDictionary.Count]; values.CopyTo(valueArray, 0); Using Values Property with CopyTo Method The ... Read More

Gets or Sets the element at the specified index in the List in C#

AmitDiwan
Updated on 17-Mar-2026 07:04:36

211 Views

In C#, you can get or set elements at a specific index in a List using the indexer property. This allows you to access and modify list elements using square bracket notation, similar to arrays. Syntax Following is the syntax for accessing elements by index − // Getting an element T element = list[index]; // Setting an element list[index] = value; Getting Elements by Index The following example demonstrates how to retrieve elements from a List using their index positions − using System; using System.Collections.Generic; public class Demo { ... Read More

Advertisements