Articles on Trending Technologies

Technical articles with clear explanations and examples

How to iterate any Map in C#

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

C# doesn't have a built-in Map type like Java. Instead, C# uses Dictionary to achieve the same functionality. A Dictionary stores key-value pairs and provides several ways to iterate through its contents. Syntax Following is the syntax for creating a Dictionary − Dictionary dictionary = new Dictionary(); Following are the common iteration patterns − // Iterate over keys foreach (var key in dictionary.Keys) { } // Iterate over values foreach (var value in dictionary.Values) { } // Iterate over key-value pairs foreach (var kvp in dictionary) { } ...

Read More

C# Linq Contains Method

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 3K+ Views

The Contains() method in LINQ is used to check whether a sequence contains a specific element. It returns true if the element is found, otherwise false. This method works with any IEnumerable collection including arrays, lists, and queryable sequences. Syntax Following is the syntax for using Contains() with collections − bool result = collection.Contains(element); Following is the syntax for using Contains() with queryable sequences − bool result = collection.AsQueryable().Contains(element); Parameters element − The value to locate in the sequence. Return Value Returns true if the ...

Read More

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

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 359 Views

The Char.ConvertToUtf32(String, Int32) method in C# is used to convert the value of a UTF-16 encoded character or surrogate pair at a specified position in a string into a Unicode code point. This method is particularly useful when working with Unicode characters that may be represented as surrogate pairs in UTF-16 encoding. Syntax Following is the syntax − public static int ConvertToUtf32(string s, int index); Parameters s − The string that contains a character or surrogate pair. index − The index position of the character or surrogate pair in ...

Read More

C# Program to display name of Current Thread

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

To display the name of the current thread in C#, use the Name property of the Thread.CurrentThread object. This property allows you to both set and retrieve the name of the currently executing thread. Syntax Following is the syntax to get the current thread − Thread thread = Thread.CurrentThread; Following is the syntax to set and get the thread name − thread.Name = "ThreadName"; string currentName = thread.Name; Using Thread.CurrentThread Property The Thread.CurrentThread property returns a reference to the currently executing thread. You can then use the Name property ...

Read More

Methods of the Thread Class

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 759 Views

The Thread class in C# provides several methods to control and manage thread execution. The most commonly used methods are Start(), Sleep(), Join(), and Abort() (though Abort() is obsolete in .NET Core and later versions). Commonly Used Thread Methods Method Description Start() Starts the execution of a thread Sleep(int milliseconds) Pauses the current thread for specified time Join() Blocks calling thread until this thread terminates Interrupt() Interrupts a thread in WaitSleepJoin state Using Start() and Join() Methods The Start() method ...

Read More

How to iterate efficiently through an array of integers of unknown size in C#

Samual Sam
Samual Sam
Updated on 17-Mar-2026 587 Views

To iterate efficiently through an array of integers of unknown size in C#, there are several approaches available. The key is to use the array's Length property or built-in iteration methods that automatically handle the array size. Syntax Following is the syntax for basic array iteration using a for loop − for (int i = 0; i < arr.Length; i++) { // access arr[i] } Following is the syntax for using foreach loop − foreach (int element in arr) { // access element directly ...

Read More

C# Program to search for a string in an array of strings

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

Searching for a string in an array of strings is a common programming task. C# provides several methods to accomplish this, with the most straightforward being the LINQ Contains() method. This method returns a boolean value indicating whether the specified string exists in the array. Syntax Following is the syntax for using Contains() method to search in an array − array.Contains(searchString) You can also use it with AsQueryable() for LINQ queries − array.AsQueryable().Contains(searchString) Using LINQ Contains() Method The simplest approach is to use the LINQ Contains() method which returns ...

Read More

Infinity or Exception in C# when divide by 0?

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 2K+ Views

When dividing by zero in C#, the behavior depends on the data type being used. Integer division by zero throws a DivideByZeroException, while floating-point division by zero returns Infinity or NaN (Not a Number) without throwing an exception. Syntax Following is the basic division syntax that can result in divide-by-zero scenarios − result = dividend / divisor; Exception handling syntax for integer division − try { result = dividend / divisor; } catch (DivideByZeroException ex) { // handle exception } Integer Division ...

Read More

How to iterate over a C# dictionary?

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

A Dictionary in C# is a collection of key-value pairs that can be iterated using several different approaches. Each method provides access to keys, values, or both simultaneously. Syntax Following is the syntax for declaring and initializing a Dictionary − Dictionary dict = new Dictionary(); dict.Add(key, value); Following are the common iteration patterns − // Using KeyValuePair foreach (KeyValuePair pair in dict) { // Access pair.Key and pair.Value } // Using Keys collection foreach (TKey key in dict.Keys) { // Access key and dict[key] } ...

Read More

C# Linq Count method

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 754 Views

The Count method in LINQ returns the number of elements in a sequence. It is one of the most commonly used LINQ methods for determining collection size and can be used with arrays, lists, and any IEnumerable collection. Syntax Following is the syntax for the basic Count method − int count = collection.Count(); Following is the syntax for Count with a predicate condition − int count = collection.Count(predicate); Using Count() on Arrays and Collections The Count method can be applied to any collection that implements IEnumerable. Here's how to ...

Read More
Showing 11111–11120 of 61,297 articles
Advertisements