Programming Articles

Page 76 of 2547

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

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

A row-wise and column-wise sorted matrix has elements arranged in ascending order both horizontally (across rows) and vertically (down columns). This creates a special structure that allows for efficient searching algorithms beyond simple linear traversal. The most straightforward approach is to treat the sorted 2D matrix as a flattened 1D array and apply binary search. Since elements maintain sorted order when concatenated row by row, we can use index mapping to convert 1D positions back to 2D coordinates. Syntax Following is the syntax for converting between 1D and 2D indices in a matrix − // ...

Read More

Single.GetTypeCode Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 144 Views

The Single.GetTypeCode() method in C# is used to return the TypeCode for the Single value type (also known as float). This method is inherited from the IConvertible interface and always returns TypeCode.Single for any float value. Syntax Following is the syntax for the Single.GetTypeCode() method − public TypeCode GetTypeCode(); Return Value This method returns TypeCode.Single, which is an enumerated constant representing the Single data type. Using GetTypeCode with Different Float Values Example using System; public class Demo { public static void Main() { ...

Read More

How to find the MaxCapacity of a StringBuilder in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 305 Views

The MaxCapacity property of a StringBuilder in C# returns the maximum number of characters that the StringBuilder can hold. This is a read-only property that represents the theoretical upper limit for the StringBuilder's capacity. In most cases, the MaxCapacity is set to Int32.MaxValue (2, 147, 483, 647), which is the maximum value for a 32-bit signed integer. However, you can specify a custom maximum capacity when creating a StringBuilder using specific constructor overloads. Syntax Following is the syntax to access the MaxCapacity property − int maxCapacity = stringBuilder.MaxCapacity; Following is the syntax to ...

Read More

Stack.Pop() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 1K+ Views

The Stack.Pop() method in C# is used to remove and return the object at the top of the Stack. This method follows the LIFO (Last In, First Out) principle, where the most recently added element is the first one to be removed. Syntax Following is the syntax for the Pop() − public virtual object Pop(); Return Value The Pop() method returns the object that was removed from the top of the Stack. If the Stack is empty, it throws an InvalidOperationException. How Stack.Pop() Works Stack.Pop() Operation ...

Read More

OrderedDictionary Class in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 1K+ Views

The OrderedDictionary class in C# represents a collection of key/value pairs that maintains insertion order and allows access by both key and index. It combines the functionality of a dictionary with the ordered nature of a list, making it useful when you need to preserve the order of items while still providing fast key-based lookup. Syntax Following is the syntax for creating and using an OrderedDictionary − OrderedDictionary dict = new OrderedDictionary(); dict.Add(key, value); dict[key] = value; // Access by key dict[index] = value; // Access by index ...

Read More

What is the Item property of BitArray class in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 143 Views

The Item property of the BitArray class in C# gets or sets the value of the bit at a specific position in the BitArray. This property acts as an indexer, allowing you to access individual bits using bracket notation like bitArray[index]. The Item property provides a convenient way to read and modify individual bits without having to use explicit method calls. It returns a bool value representing the bit state at the specified index. Syntax Following is the syntax for accessing the Item property − public bool this[int index] { get; set; } ...

Read More

C# program to find Largest, Smallest, Second Largest, Second Smallest in a List

Samual Sam
Samual Sam
Updated on 17-Mar-2026 2K+ Views

Finding the largest, smallest, second largest, and second smallest elements in a list is a common programming task in C#. Using LINQ methods like Max(), Min(), OrderBy(), and Skip() provides an elegant solution for these operations. Syntax To find the largest element − list.Max() To find the smallest element − list.Min() To find the second largest element − list.OrderByDescending(x => x).Skip(1).First() To find the second smallest element − list.OrderBy(x => x).Skip(1).First() Using LINQ Methods The most straightforward approach uses LINQ extension ...

Read More

How to access array elements using a pointer in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 4K+ Views

In C#, accessing array elements using pointers requires understanding the key differences between arrays and pointers. An array name and a pointer to the same data type are not the same variable type. For example, int *p and int[] p represent different types. You can increment a pointer variable because it's not fixed in memory, but an array address is fixed in memory and cannot be incremented directly. To access array elements using pointers in C#, you must use unsafe code and the fixed statement to pin the array in memory temporarily. Syntax Following is the syntax ...

Read More

Multiple Where clause in C# Linq

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 5K+ Views

In C# LINQ, you can apply multiple where clauses to filter collections based on different conditions. Each additional where clause further narrows down the results, creating a logical AND relationship between the conditions. Syntax There are two main approaches to using multiple where clauses − Query Syntax with Multiple Where Clauses: var result = from item in collection where condition1 where condition2 ...

Read More

What is the Keys property of Hashtable class in C#?

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 164 Views

The Keys property of the Hashtable class in C# returns an ICollection containing all the keys in the hashtable. This property is useful for iterating through all keys or performing operations on the key collection without accessing the values. Syntax Following is the syntax for accessing the Keys property − public virtual ICollection Keys { get; } Return Value The Keys property returns an ICollection object that contains all the keys in the hashtable. The order of keys is not guaranteed as hashtables do not maintain insertion order. Using Keys Property to ...

Read More
Showing 751–760 of 25,467 articles
« Prev 1 74 75 76 77 78 2547 Next »
Advertisements