Articles on Trending Technologies

Technical articles with clear explanations and examples

Default value of bool in C#

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

The default operator in C# returns the default value for any data type. For the bool type, the default value is false. When a bool variable is declared without initialization, it automatically gets assigned the default value of false. Syntax Following is the syntax for using the default operator with bool − bool variable = default(bool); In C# 7.1 and later, you can also use the simplified syntax − bool variable = default; Using default(bool) Operator The following example demonstrates how to get the default value of bool ...

Read More

Dictionary.ContainsValue() Method in C#

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

The Dictionary.ContainsValue() method in C# is used to check whether the Dictionary contains a specific value or not. This method returns true if the value is found in the dictionary, otherwise it returns false. Syntax public bool ContainsValue(TValue val); Parameters val − The value to search for in the dictionary. This parameter can be null if the value type allows null values. Return Value Returns true if the dictionary contains the specified value; otherwise, false. Using ContainsValue() with Found Value The following example demonstrates checking for a value that exists ...

Read More

UInt32.ToString() Method in C# with Examples

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

The UInt32.ToString() method in C# is used to convert the numeric value of a UInt32 instance to its equivalent string representation. This method is particularly useful when you need to display unsigned 32-bit integer values as text or concatenate them with strings. The UInt32 type represents unsigned 32-bit integers with values ranging from 0 to 4, 294, 967, 295. The ToString() method provides several overloads to format the output according to different requirements. Syntax Following are the main syntax variations of the UInt32.ToString() method − public override string ToString(); public string ToString(string format); public string ...

Read More

How to use the sleep method in C#?

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

The Thread.Sleep() method in C# is used to pause the execution of the current thread for a specified period of time. This is commonly used to introduce delays in program execution or to simulate time-consuming operations. Syntax The Thread.Sleep() method has two overloads − Thread.Sleep(int millisecondsTimeout); Thread.Sleep(TimeSpan timeout); Parameters millisecondsTimeout − The number of milliseconds for which the thread is suspended. Use Timeout.Infinite (-1) to suspend the thread indefinitely. timeout − A TimeSpan that sets the amount of time for which the thread is suspended. Using Thread.Sleep() with Milliseconds ...

Read More

How to check if a string is a valid keyword in C#?

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

To check if a string is a valid keyword in C#, you can use the IsValidIdentifier method from the CodeDomProvider class. This method determines whether a given string is a valid identifier or a reserved keyword in C#. The IsValidIdentifier method returns true if the string is a valid identifier (like variable names, method names), and false if it's a reserved keyword (like for, if, class, etc.). Syntax Following is the syntax for using IsValidIdentifier method − CodeDomProvider provider = CodeDomProvider.CreateProvider("C#"); bool isIdentifier = provider.IsValidIdentifier(stringToCheck); Using IsValidIdentifier to Check Keywords Here's how ...

Read More

The nameof keyword in C#

George John
George John
Updated on 17-Mar-2026 685 Views

The nameof operator in C# returns the string literal name of a variable, type, or member. It provides a compile-time constant string that represents the name of the code element, making it useful for logging, exception messages, and property change notifications without hardcoding strings. Syntax Following is the syntax for using the nameof operator − string name = nameof(element); Where element can be a variable, property, method, class, or namespace. Using nameof with Variables The nameof operator returns the variable name as a string, which is resolved at compile time − ...

Read More

C# Program to add a node before the given node in a Linked List

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

A LinkedList in C# is a doubly-linked list that allows efficient insertion and deletion of nodes at any position. The AddBefore() method inserts a new node immediately before a specified existing node in the linked list. Syntax Following is the syntax for the AddBefore() method − public LinkedListNode AddBefore(LinkedListNode node, T value) public LinkedListNode AddBefore(LinkedListNode node, LinkedListNode newNode) Parameters node − The existing LinkedListNode before which to insert the new node. value − The value to add to the LinkedList. newNode − The new LinkedListNode to add ...

Read More

Uri.EscapeDataString(String) Method in C#

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

The Uri.EscapeDataString() method in C# converts a string to its escaped representation by encoding characters that are not safe for use in URI data strings. This method is essential when you need to include user data or special characters in URL components like query parameters. Syntax Following is the syntax − public static string EscapeDataString(string stringToEscape); Parameters stringToEscape: A string that contains the data to be escaped. If the string is null, the method returns null. Return Value Returns a string that contains the escaped representation of stringToEscape. How It ...

Read More

How to use RightShift Operators in C#?

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

The right shift operator (>>) in C# moves the bits of the left operand to the right by the number of positions specified by the right operand. This operation effectively divides the number by powers of 2. Syntax Following is the syntax for the right shift operator − result = operand >> numberOfPositions; Where operand is the value whose bits will be shifted, and numberOfPositions specifies how many positions to shift right. How Right Shift Works The right shift operator moves each bit to the right by the specified number of positions. ...

Read More

C# program to find K'th smallest element in a 2D array

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

Finding the K'th smallest element in a 2D array requires flattening the array and sorting it to locate the element at the K'th position. This is a common programming problem that demonstrates array manipulation and sorting techniques. Approach The approach involves three main steps − Flatten the 2D array into a 1D array Sort the flattened array in ascending order Access the element at index k-1 (since arrays are zero-indexed) Finding K'th Smallest Element 2D Array ...

Read More
Showing 10581–10590 of 61,299 articles
Advertisements