Programming Articles

Page 98 of 2547

C# Program to Reverse the List of Cities using LINQ

Sabid Ansari
Sabid Ansari
Updated on 17-Mar-2026 348 Views

In C#, LINQ (Language Integrated Query) is a powerful feature that allows us to perform queries on various data sources, including arrays, lists, and databases. It provides an efficient and concise way to manipulate data and has become an essential tool for developers. In this article, we will explore how to use LINQ to reverse a list of cities in C#. LINQ is a set of extensions to the .NET Framework that provides a standard way to query data from different data sources using a common syntax. It allows developers to write queries that resemble SQL statements, making it ...

Read More

How to find the target sum from the given array by backtracking using C#?

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

The target sum problem involves finding all possible combinations from a given array where the sum of elements equals a specific target value. The backtracking approach systematically explores all possible combinations by adding elements to the current solution and removing them when they don't lead to a valid result. Given an array of positive integers and a target sum, we need to find all combinations where elements can be reused and their sum equals the target. For example, with array [1, 2, 3] and target 4, valid combinations are [1, 1, 1, 1], [1, 1, 2], [1, 3], and ...

Read More

How to change the CursorSize of the Console in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 279 Views

The Console.CursorSize property in C# allows you to change the size of the cursor in the console window. The cursor size is specified as a percentage of the character cell height, ranging from 1 to 100. Syntax Following is the syntax for setting the cursor size − Console.CursorSize = value; Parameters value − An integer between 1 and 100, representing the cursor size as a percentage of the character cell height. Using Console.CursorSize Property The cursor size can be set to different values to make it more ...

Read More

C# BitConverter.ToChar() Method

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 250 Views

The BitConverter.ToChar() method in C# converts two consecutive bytes from a byte array into a Unicode character. This method reads two bytes starting at a specified position and interprets them as a 16-bit Unicode character using little-endian byte order. Syntax public static char ToChar(byte[] value, int startIndex); Parameters value − The byte array containing the bytes to convert. startIndex − The starting position within the byte array. Two consecutive bytes are read from this position. Return Value Returns a char value formed by combining two bytes ...

Read More

Removing the node at the start of the LinkedList in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 136 Views

The LinkedList class in C# provides the RemoveFirst() method to remove the node at the start of the linked list. This method removes the first node and automatically updates the list's internal structure and count. Syntax Following is the syntax for removing the first node from a LinkedList − linkedList.RemoveFirst(); The method throws an InvalidOperationException if the LinkedList is empty. RemoveFirst() Operation One Two Three Four ...

Read More

C# Program to Merge Two Hashtable Collections

Shilpa Nadkarni
Shilpa Nadkarni
Updated on 17-Mar-2026 751 Views

The Hashtable collection in C# stores key-value pairs where each element is a DictionaryEntry object. The key is unique and non-null, used to access elements in the hashtable. Values can be null or duplicated, but the combination of key-value pairs must be unique. Since the Hashtable class doesn't provide a built-in merge method, we need to implement our own approach by iterating through one hashtable and adding its elements to another while checking for duplicate keys. Syntax Following is the syntax for creating and populating a Hashtable − Hashtable hashtableName = new Hashtable(); hashtableName.Add(key, value); ...

Read More

Difference Between dispose() and finalize() in C#

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

In this article, we will understand the difference between the Dispose() and Finalize() methods in C#. Both methods are used for resource cleanup, but they serve different purposes and are invoked in different ways during the object lifecycle. The Dispose() method provides deterministic cleanup where you control exactly when resources are freed, while Finalize() provides a safety net for cleanup that runs during garbage collection. Syntax Following is the syntax for implementing Dispose() method − public class MyClass : IDisposable { public void Dispose() { // ...

Read More

How to find the distinct subsets from a given array by backtracking using C#?

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

The distinct subsets problem involves finding all unique combinations of a specific size from a given array using backtracking. This technique systematically explores all possible combinations by adding elements to the current subset and then removing them to explore other possibilities. When we specify a target size, the algorithm generates all combinations that contain exactly that many elements. For example, with array [1, 2, 3] and target size 2, we get combinations "1, 2", "1, 3", and "2, 3". How Backtracking Works for Subsets The backtracking algorithm follows these steps − Choose − Add an ...

Read More

Single.Equals() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 134 Views

The Single.Equals() method in C# is used to return a value indicating whether two instances of Single represent the same value. The Single type is an alias for float in C#, so this method compares floating-point values for equality. Syntax The Single.Equals() method has two overloads − public bool Equals(float obj); public override bool Equals(object obj); Parameters obj − The object or float value to compare with the current instance. Return Value Returns true if the specified value is equal to the current instance; otherwise, false. For the object overload, it ...

Read More

Get an ICollection containing the keys in ListDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 127 Views

The ListDictionary class in C# provides a Keys property that returns an ICollection containing all the keys in the dictionary. This is useful when you need to iterate through or process only the keys without accessing their corresponding values. Syntax Following is the syntax to get the keys collection from a ListDictionary − ICollection keys = listDictionary.Keys; Return Value The Keys property returns an ICollection object that contains all the keys from the ListDictionary. The keys are returned in the same order as they were added to the dictionary. Using Keys Property ...

Read More
Showing 971–980 of 25,467 articles
« Prev 1 96 97 98 99 100 2547 Next »
Advertisements