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 716 of 2547
How to check whether a List contains the elements that match the specified conditions in C#?
To check whether a List contains elements that match specific conditions in C#, you can use the Exists() method. This method takes a predicate (a function that returns true or false) and returns true if at least one element in the list satisfies the condition. Syntax Following is the syntax for using List.Exists() method − public bool Exists(Predicate match) Parameters match − The predicate delegate that defines the conditions to check against the elements. Return Value Returns true if the List contains one or more elements that match the ...
Read MoreC# Program to Get Key based on Value in Hashtable Collection
A hashtable is a collection in C# that holds items identified as key-value pairs. Unlike other data structures like the stack, queue, or ArrayList that store a single value, a hashtable stores two values that form an element − the key and the value. In a hashtable, the keys are unique and cannot be null. The values can be null and duplicated. The System.Collections namespace provides the Hashtable class with various constructors, methods, and properties to perform operations on hashtable objects. This article demonstrates how to retrieve a key from a hashtable collection based on a specific value. ...
Read MoreHow to get all the combinations of the keypad value in a mobile by backtracking using C#?
The problem of generating all possible letter combinations from mobile keypad digits can be solved efficiently using backtracking. This approach explores all possible paths by making choices, exploring them recursively, and backtracking when a complete combination is formed. On a traditional mobile keypad, each digit from 2-9 corresponds to a set of letters. The goal is to find all possible combinations when given a sequence of digits. Mobile Keypad Mapping 2 ABC 3 DEF 4 ...
Read MoreHow 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 More