Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Programming Articles
Page 116 of 2547
How to change the CursorLeft of the Console in C#?
The Console.CursorLeft property in C# allows you to set or get the horizontal position of the cursor within the console window. This property is useful for positioning text at specific columns, creating formatted output, or building text-based user interfaces. Syntax Following is the syntax for setting the cursor's left position − Console.CursorLeft = columnPosition; To get the current cursor position − int currentPosition = Console.CursorLeft; Parameters The CursorLeft property accepts an integer value representing the column position (0-based indexing) where the cursor should be positioned. The value must be ...
Read MoreGet the number of key/value pairs in the StringDictionary in C#
The StringDictionary class in C# provides the Count property to get the number of key/value pairs stored in the dictionary. This property is useful for determining the size of the collection and performing operations based on the dictionary's length. Syntax Following is the syntax to get the count of key/value pairs in a StringDictionary − int count = stringDictionary.Count; Return Value The Count property returns an integer representing the number of key/value pairs currently stored in the StringDictionary. Using Count Property with Basic StringDictionary Example using System; using System.Collections; ...
Read MoreC# Program to Reverse the List of Cities using LINQ
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 MoreHow to find the target sum from the given array by backtracking using C#?
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 MoreHow to change the CursorSize of the Console in C#?
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 MoreC# BitConverter.ToChar() Method
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 MoreRemoving the node at the start of the LinkedList in C#
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 MoreC# Program to Merge Two Hashtable Collections
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 MoreDifference Between dispose() and finalize() in C#
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 MoreHow to find the distinct subsets from a given array by backtracking using C#?
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