Articles on Trending Technologies

Technical articles with clear explanations and examples

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

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 211 Views

In C#, the SortedList class provides the GetByIndex() method to retrieve the value at a specific index position. Unlike dictionary access by key, this method allows you to access values by their ordered position within the sorted collection. Syntax Following is the syntax for using GetByIndex() method − public virtual object GetByIndex(int index); Parameters index: The zero-based index of the value to retrieve from the SortedList. Return Value The method returns an object representing the value at the specified index position. If the index is out of ...

Read More

Find the last node in LinkedList containing the specified value in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 252 Views

The FindLast() method in C# LinkedList is used to find the last occurrence of a node containing the specified value. This method searches from the end of the LinkedList towards the beginning and returns the last LinkedListNode that contains the specified value. Syntax Following is the syntax for the FindLast() method − public LinkedListNode FindLast(T value) Parameters value − The value to locate in the LinkedList. Return Value Returns the last LinkedListNode that contains the specified value, or null if the value is not found. Using FindLast() with ...

Read More

How to return custom result type from an action method in C# ASP.NET WebAPI?

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

In ASP.NET Web API, you can create custom result types by implementing the IHttpActionResult interface. This interface provides a flexible way to customize HTTP responses beyond the standard return types like Ok(), BadRequest(), or NotFound(). The IHttpActionResult interface contains a single method that asynchronously creates an HttpResponseMessage instance, giving you full control over the HTTP response. Syntax The IHttpActionResult interface has the following structure − public interface IHttpActionResult { Task ExecuteAsync(CancellationToken cancellationToken); } How It Works When a controller action returns an IHttpActionResult, Web API calls the ExecuteAsync ...

Read More

Getting the Values in a SortedList object in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 228 Views

The SortedList class in C# is a collection that stores key-value pairs sorted by the keys. To retrieve all values from a SortedList object, you can use the Values property, which returns an ICollection containing all the values in sorted order of their corresponding keys. Syntax Following is the syntax for accessing values in a SortedList − SortedList sortedList = new SortedList(); ICollection values = sortedList.Values; The Values property returns an ICollection that can be iterated using a foreach loop − foreach (var value in sortedList.Values) { Console.WriteLine(value); } ...

Read More

How to resolve CORS issue in C# ASP.NET WebAPI?

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

Cross-Origin Resource Sharing (CORS) is a security mechanism that uses additional HTTP headers to allow web applications running at one origin to access selected resources from a different origin. A web application executes a cross-origin HTTP request when it requests a resource that has a different origin (domain, protocol, or port) from its own. For example, consider an application with its front-end served from https://demodomain-ui.com and backend from https://demodomain-service.com/api. When the UI tries to make API calls to the backend, browsers restrict these cross-origin HTTP requests for security reasons, resulting in CORS errors. CORS ...

Read More

Check if SortedSet and the specified collection contain the same elements in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 188 Views

The SetEquals method in C# is used to check if a SortedSet and another collection contain exactly the same elements. This method returns true if both collections have identical elements, regardless of their order, and false otherwise. Syntax Following is the syntax for using the SetEquals method − public bool SetEquals(IEnumerable other) Parameters other − The collection to compare with the current SortedSet. Return Value Returns true if the SortedSet and the specified collection contain the same elements; otherwise, false. Using SetEquals with Different Elements ...

Read More

Get a specific type nested within the current Type in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 184 Views

The GetNestedType() method in C# is used to retrieve a specific nested type (inner class) from within the current type. This method is part of the Type class and helps in reflection scenarios where you need to access inner classes dynamically. Syntax Following is the syntax for the GetNestedType() method − public Type GetNestedType(string name) public Type GetNestedType(string name, BindingFlags bindingAttr) Parameters name − The name of the nested type to retrieve. bindingAttr − Optional. Specifies how the search is conducted (public, non-public, etc.). Return Value Returns a Type ...

Read More

What are the different types of filters in C# ASP.NET WebAPI?

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

Filters in ASP.NET Web API provide a way to inject additional logic at different stages of request processing. They enable cross-cutting concerns such as authentication, authorization, logging, and caching without cluttering your controller logic. Filters can be applied declaratively using attributes or programmatically, offering flexibility in how you handle these concerns. Web API supports several types of filters, each serving a specific purpose in the request pipeline. Understanding these filter types helps you choose the right approach for implementing various functionalities in your API. Types of Filters Web API Filter Pipeline ...

Read More

C# Program to Check if a Number is Perfect

AYUSH MISHRA
AYUSH MISHRA
Updated on 17-Mar-2026 12K+ Views

A perfect number is a positive integer that equals the sum of its proper divisors (all divisors excluding the number itself). For example, 6 is perfect because its proper divisors (1, 2, and 3) sum to 6. Proper divisors are numbers that divide evenly into the given number without leaving a remainder. Perfect Number: 6 1 2 3 = 6 6 ÷ 1 = 6 6 ÷ 2 = ...

Read More

Get an IDictionaryEnumerator object in OrderedDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 241 Views

The OrderedDictionary class in C# provides the GetEnumerator() method to obtain an IDictionaryEnumerator object. This enumerator allows you to iterate through the key-value pairs while maintaining the insertion order of elements. The IDictionaryEnumerator is specifically designed for dictionary collections and provides access to both the Key and Value properties of each element during enumeration. Syntax Following is the syntax for getting an IDictionaryEnumerator from an OrderedDictionary − IDictionaryEnumerator enumerator = orderedDictionary.GetEnumerator(); Following is the syntax for iterating through the enumerator − while (enumerator.MoveNext()) { Console.WriteLine("Key = " + enumerator.Key + ", Value = " + enumerator.Value); } Return Value The GetEnumerator()

Read More
Showing 10081–10090 of 61,299 articles
Advertisements