Articles on Trending Technologies

Technical articles with clear explanations and examples

SByte.GetTypeCode Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 117 Views

The SByte.GetTypeCode() method in C# is used to return the TypeCode enumeration value for the sbyte data type. This method is part of the IConvertible interface and helps identify the specific type of a value at runtime. Syntax Following is the syntax for the SByte.GetTypeCode() method − public TypeCode GetTypeCode(); Return Value The method returns TypeCode.SByte, which is the enumeration constant representing the sbyte type. Using GetTypeCode() with SByte Values Example using System; public class Demo { public static void Main() { ...

Read More

How to create an OrderedDictionary in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 143 Views

An OrderedDictionary in C# is a specialized collection that maintains the insertion order of key-value pairs. Unlike a regular Dictionary, it preserves the sequence in which elements were added, making it useful when order matters. The OrderedDictionary class is part of the System.Collections.Specialized namespace and provides both indexed access and key-based access to elements. Syntax Following is the syntax for creating an OrderedDictionary − OrderedDictionary dict = new OrderedDictionary(); dict.Add(key, value); dict[index] = value; // Access by index dict[key] = value; // Access by key Creating and Populating an ...

Read More

Queue.IsSynchronized Property in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 150 Views

The Queue.IsSynchronized property in C# is used to determine whether access to the Queue is synchronized, meaning it is thread-safe for concurrent access by multiple threads. Syntax Following is the syntax for the IsSynchronized property − public virtual bool IsSynchronized { get; } Return Value The property returns a bool value − true − if access to the Queue is synchronized (thread-safe) false − if access to the Queue is not synchronized Using IsSynchronized with Regular Queue By default, a regular Queue is not synchronized and returns false ...

Read More

How to search in a row wise increased matrix using C#?

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

Searching in a row-wise sorted matrix is a common algorithmic problem where each row and column is sorted in ascending order. The naive approach of scanning all elements takes O(M×N) time complexity, but we can optimize this using a smart traversal strategy. The key insight is to start from either the top-right corner or bottom-left corner of the matrix. From the top-right position, if the target is smaller than the current element, move left; if larger, move down. This approach eliminates either a row or column in each step. Algorithm The search algorithm works as follows − ...

Read More

Queue.Peek Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 455 Views

The Queue.Peek() method in C# is used to return the object at the beginning of the Queue without removing it. This method is useful when you need to examine the first element in the queue without modifying the queue's contents. Syntax Following is the syntax for the non-generic Queue − public virtual object Peek(); Following is the syntax for the generic Queue − public T Peek(); Return Value The method returns the object at the beginning of the Queue. For generic queues, it returns type T, and for non-generic ...

Read More

Total number of elements present in an array in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 237 Views

In C#, you can get the total number of elements present in an array using several different approaches. The most common methods are using the Length property, GetLength() method, or LongLength property for very large arrays. Syntax Following are the different ways to get array length − // Using Length property (most common) int count = arrayName.Length; // Using GetLength() method for specific dimension int count = arrayName.GetLength(0); // Using LongLength for very large arrays long count = arrayName.LongLength; Using Length Property The Length property is the most commonly used approach ...

Read More

C# Program to Find the Sum of First N Natural Numbers

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

We are given a number N, and we need to calculate the sum of the first N natural numbers. Natural numbers are positive integers starting from 1 (i.e., 1, 2, 3, 4, 5, ...). In this article, we are going to learn how we can find the sum of the first N natural numbers in C#. Sum of First N Natural Numbers N = 5 1 2 3 4 ...

Read More

How to find all unique triplets that adds up to sum Zero using C#?

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

The three-sum problem involves finding all unique triplets in an array that sum to zero. This is a classic algorithmic challenge that can be solved efficiently using a two-pointer technique after sorting the array. Problem Statement Given an array of integers, find all unique triplets where nums[i] + nums[j] + nums[k] = 0. The solution must avoid duplicate triplets. Approach 1: Brute Force The simplest approach uses three nested loops to check every possible combination of three elements − Time Complexity − O(n³) Space Complexity − O(1) Approach 2: Optimized Two-Pointer Technique ...

Read More

Single.IsNaN() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 233 Views

The Single.IsNaN() method in C# is used to determine whether a specified float value is not a number (NaN). This method returns true if the value is NaN, and false otherwise. NaN typically results from undefined mathematical operations like dividing zero by zero. Syntax Following is the syntax for the Single.IsNaN() method − public static bool IsNaN(float f); Parameters f − A single-precision floating-point number to be tested. Return Value Returns true if the value is NaN (Not a Number), otherwise false. ...

Read More

Stack.Synchronized() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 145 Views

The Stack.Synchronized() method in C# returns a synchronized (thread-safe) wrapper for a Stack. This wrapper ensures that all operations on the stack are thread-safe, making it suitable for use in multi-threaded applications where multiple threads might access the same stack simultaneously. Syntax Following is the syntax for the Stack.Synchronized() method − public static System.Collections.Stack Synchronized(System.Collections.Stack stack); Parameters stack − The Stack object to synchronize. Return Value Returns a synchronized wrapper for the specified Stack. The returned wrapper provides thread-safe access to all Stack operations. Stack.Synchronized() Wrapper ...

Read More
Showing 1–10 of 61,302 articles
« Prev 1 2 3 4 5 6131 Next »
Advertisements