In C#, the Hashtable class provides the Count property to determine the number of key/value pairs stored in the collection. This property returns an integer value representing the total count of elements currently in the Hashtable. Syntax Following is the syntax for accessing the Count property − int count = hashtable.Count; Parameters The Count property does not take any parameters. It is a read-only property that returns the current number of key/value pairs in the Hashtable. Return Value The Count property returns an int value representing the total number of key/value ... Read More
ASP.NET Web API controller actions can return different types depending on your application's requirements. Understanding these return types helps you choose the most appropriate approach for your specific scenarios. Available Return Types Void − Returns no content with HTTP 204 status Primitive/Complex Types − Returns data directly with automatic serialization HttpResponseMessage − Provides full control over the HTTP response IHttpActionResult − Offers a cleaner, testable approach to response creation Web API Return Type Evolution Void 204 No Content Primitive/ ... Read More
In C#, you can use reflection to inspect the members of a type at runtime. The Type.GetMembers() method returns an array of MemberInfo objects representing all public members of a type, including fields, properties, methods, constructors, and events. Syntax Following is the syntax to get all members of a type − Type type = typeof(ClassName); MemberInfo[] members = type.GetMembers(); To filter members using binding flags − MemberInfo[] members = type.GetMembers(BindingFlags.Public | BindingFlags.Instance); Using GetMembers() Without Binding Flags When called without parameters, GetMembers() returns all public members including inherited ones ... Read More
The HybridDictionary class in C# is a collection that combines the performance benefits of both ListDictionary and Hashtable. It automatically switches between these implementations based on the number of elements. For small collections, it uses ListDictionary, and for larger collections, it switches to Hashtable for better performance. When creating a HybridDictionary, you can specify whether it should be case-sensitive or case-insensitive through its constructor parameter. Syntax Following is the syntax for creating a case-sensitive HybridDictionary − HybridDictionary dict = new HybridDictionary(false); Following is the syntax for creating a case-insensitive HybridDictionary − ... Read More
The HybridDictionary class in C# is a collection that combines the benefits of both ListDictionary and Hashtable. It automatically switches from a list-based implementation to a hash table when the collection grows beyond a certain size. By default, HybridDictionary is case-sensitive, but you can specify case sensitivity behavior during initialization. Syntax Following is the syntax for creating an empty HybridDictionary with default case sensitivity − HybridDictionary dictionary = new HybridDictionary(); Following is the syntax for creating an empty HybridDictionary with specified case sensitivity − HybridDictionary dictionary = new HybridDictionary(bool caseInsensitive); ... Read More
The GetTypeCode() method in C# returns a TypeCode enumeration that identifies the type of a value. For Int16 (short) values, this method consistently returns TypeCode.Int16 regardless of the actual numeric value stored. Syntax Following is the syntax for getting the TypeCode of an Int16 value − TypeCode typeCode = int16Variable.GetTypeCode(); Return Value The GetTypeCode() method returns TypeCode.Int16 for all short variables, which represents the 16-bit signed integer type. Using GetTypeCode() with Int16 Values Example using System; public class Demo { public static void Main() { ... Read More
The SortedSet class in C# represents a collection of objects that is maintained in sorted order. Unlike regular sets, SortedSet automatically keeps elements sorted and ensures uniqueness − duplicate elements are not allowed. SortedSet is part of the System.Collections.Generic namespace and provides efficient operations for adding, removing, and searching elements while maintaining the sorted order. Syntax Following is the syntax for creating and using a SortedSet − SortedSet setName = new SortedSet(); setName.Add(element); Key Properties Property Description Comparer Gets the IComparer object that is used ... Read More
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
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
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
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Economics & Finance