AmitDiwan

AmitDiwan

8,392 Articles Published

Articles by AmitDiwan

Page 183 of 840

Remove the specified element from a HashSet in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 501 Views

A HashSet in C# is a collection that stores unique elements without any specific order. To remove a specified element from a HashSet, you use the Remove() method, which returns true if the element was found and removed, or false if the element was not present. Syntax The Remove() method follows this syntax − public bool Remove(T item) Parameters item − The element to remove from the HashSet. Return Value The method returns true if the element was successfully found and removed; otherwise, false. ...

Read More

Char.IsHighSurrogate(String, Int32) Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 237 Views

The Char.IsHighSurrogate(String, Int32) method in C# determines whether the character at the specified position in a string is a high surrogate. High surrogates are Unicode code units in the range U+D800 to U+DBFF, used as the first part of surrogate pairs to represent characters beyond the Basic Multilingual Plane. Syntax Following is the syntax − public static bool IsHighSurrogate(string str, int index); Parameters str − The string to evaluate. index − The position of the character to evaluate in the string. Return Value Returns true ...

Read More

Remove a range of elements from the List in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 534 Views

The RemoveRange() method in C# allows you to remove multiple elements from a List at once by specifying a starting index and the number of elements to remove. This is more efficient than removing elements one by one. Syntax Following is the syntax for the RemoveRange() method − public void RemoveRange(int index, int count) Parameters index − The zero-based starting index of the range of elements to remove. count − The number of elements to remove starting from the specified index. RemoveRange(1, 3) Example ...

Read More

Char.IsLetter() Method in C#

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

The Char.IsLetter() method in C# is used to determine whether a specified Unicode character is categorized as a Unicode letter. This method returns true if the character is a letter (uppercase or lowercase), and false otherwise. This method is particularly useful for input validation, text processing, and character classification in applications where you need to distinguish letters from numbers, symbols, or other character types. Syntax Following is the syntax − public static bool IsLetter(char ch); Parameters ch − The Unicode character to evaluate. Return Value Returns ...

Read More

Removing first occurrence of object from Collection in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 186 Views

The Collection.Remove() method in C# removes the first occurrence of a specified object from the collection. This method searches through the collection sequentially and removes only the first matching element it encounters, leaving any subsequent duplicates unchanged. Syntax Following is the syntax for the Remove() method − public bool Remove(T item) Parameters item: The object to remove from the collection. The value can be null for reference types. Return Value The method returns a bool value − true: If the item was successfully found and removed false: ...

Read More

Removing first occurrence of specified value from LinkedList in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 350 Views

The LinkedList.Remove(T) method in C# removes the first occurrence of the specified value from a LinkedList. This method searches the LinkedList from the beginning and removes only the first matching node it encounters, leaving any subsequent duplicates unchanged. Syntax Following is the syntax for removing the first occurrence of a specified value − public bool Remove(T value) Parameters value: The value to remove from the LinkedList. Return Value Returns true if the element is successfully found and removed; otherwise, false. This method also returns false if the value was ...

Read More

How to change the Foreground Color of Text in C# Console?

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

To change the foreground color of text in C# console applications, use the Console.ForegroundColor property. This property accepts a ConsoleColor enumeration value and affects all subsequent text output until changed again. Syntax Following is the syntax for setting console foreground color − Console.ForegroundColor = ConsoleColor.ColorName; To reset to default colors, use − Console.ResetColor(); Available Colors The ConsoleColor enumeration provides the following color options − Color Name Description Black, DarkBlue, DarkGreen, DarkCyan Dark color variants DarkRed, DarkMagenta, DarkYellow, Gray Medium ...

Read More

Get the number of key/value pairs contained in ListDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 182 Views

To get the number of key/value pairs contained in ListDictionary, you use the Count property. The ListDictionary class in C# is part of the System.Collections.Specialized namespace and is optimized for small collections with typically fewer than 10 elements. The Count property returns an integer representing the total number of key/value pairs currently stored in the ListDictionary. Syntax Following is the syntax for getting the count of key/value pairs in ListDictionary − ListDictionary listDict = new ListDictionary(); int count = listDict.Count; Using Count Property Example using System; using System.Collections; using System.Collections.Specialized; ...

Read More

How to check whether a List contains the elements that match the specified conditions in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 496 Views

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 More

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

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 377 Views

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 More
Showing 1821–1830 of 8,392 articles
« Prev 1 181 182 183 184 185 840 Next »
Advertisements