Articles on Trending Technologies

Technical articles with clear explanations and examples

How to insert an item into a C# list by using an index?

George John
George John
Updated on 17-Mar-2026 3K+ Views

The Insert() method in C# allows you to add an item to a List at a specific index position. This method shifts existing elements to make room for the new item, automatically increasing the list's size. Syntax Following is the syntax for the Insert() method − list.Insert(index, item); Parameters index − The zero-based index at which the item should be inserted. item − The object to insert into the list. How It Works When you use Insert(), the method shifts all elements at and after ...

Read More

The "#" custom specifier in C#

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

The # custom format specifier in C# serves as a digit placeholder symbol in numeric formatting. It displays a digit only if one exists at that position, making it useful for creating flexible number formats that suppress unnecessary leading and trailing zeros. Syntax Following is the syntax for using the # format specifier − number.ToString("#formatPattern") String.Format("{0:#formatPattern}", number) How It Works When formatting a number, the # symbol represents an optional digit position. If the value has a digit at that position, it displays the digit. If not, nothing is displayed for that position. ...

Read More

C# program to find node in Linked List

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

The LinkedList class in C# provides methods to search for nodes within the list. The Find() method returns the first LinkedListNode that contains the specified value, or null if the value is not found. Syntax Following is the syntax for finding a node in a LinkedList − LinkedListNode node = linkedList.Find(value); Following is the syntax for finding the last occurrence of a node − LinkedListNode node = linkedList.FindLast(value); Return Value The Find() method returns a LinkedListNode object containing the value, or null if the value is not found. The ...

Read More

What are static members of a C# Class?

Samual Sam
Samual Sam
Updated on 17-Mar-2026 5K+ Views

Static members in C# belong to the class itself rather than to any specific instance of the class. When you declare a member as static, only one copy exists regardless of how many objects are created from the class. Static members are accessed using the class name directly, without creating an instance. They are commonly used for utility functions, constants, and shared data that should be consistent across all instances of a class. Syntax Following is the syntax for declaring static members − public static dataType memberName; public static returnType MethodName() { ...

Read More

List down a list of the escape characters in C#

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

Escape characters in C# are special character sequences that begin with a backslash (\) and represent characters that cannot be directly typed or displayed. They are commonly used in strings, regular expressions, and character literals to represent control characters, special symbols, and Unicode characters. Common Escape Characters The most frequently used escape characters include for new lines, \t for tabs, and " for quotes within strings. Example using System; class Program { static void Main() { Console.WriteLine("Hello\tWorld"); ...

Read More

Retrieve data value as a pointer in C#

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 969 Views

A pointer is a variable whose value is the address of another variable. In C#, pointers can only be used in unsafe contexts. To retrieve the data stored at the location referenced by the pointer variable, you can use the dereference operator * or call the ToString() method on the pointer. Syntax Following is the syntax for declaring and using pointers in C# − unsafe { int* ptr = &variable; // Declare pointer and get address int value = *ptr; ...

Read More

How to initialize a string to an empty string in C#?

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 4K+ Views

In C#, there are several ways to initialize a string to an empty string. Understanding the different approaches helps you choose the most appropriate method for your specific use case. Syntax Following are the different ways to initialize a string to an empty string − string myStr = ""; // Empty string literal string myStr = string.Empty; // Using string.Empty property string myStr = null; // Null reference (not ...

Read More

C# Program to generate random lowercase letter

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 2K+ Views

In C#, you can generate a random lowercase letter using the Random class and ASCII character conversion. This technique generates a random number between 0 and 25, then converts it to a corresponding lowercase letter from 'a' to 'z'. Syntax Following is the syntax for generating a random lowercase letter − Random random = new Random(); int randomIndex = random.Next(0, 26); char randomLetter = (char)('a' + randomIndex); How It Works The process involves three key steps: Generate random number: random.Next(0, 26) produces a number from 0 to 25 ...

Read More

C# Program to find a key in Dictionary

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

In C#, a Dictionary is a collection that stores key-value pairs. To check if a specific key exists in a Dictionary, you can use the ContainsKey() method, which returns true if the key is found and false otherwise. Syntax Following is the syntax for using the ContainsKey() method − bool result = dictionary.ContainsKey(key); Parameters key − The key to locate in the Dictionary. Return Value Returns true if the Dictionary contains an element with the specified key; otherwise, false. Using ContainsKey() Method The most straightforward way to ...

Read More

Convert.ToChar(String, IFormatProvider) Method in C#

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

The Convert.ToChar(String, IFormatProvider) method in C# converts the first character of a specified string to a Unicode character. This method uses culture-specific formatting information, though the IFormatProvider parameter is ignored for string-to-char conversion since character conversion doesn't depend on culture. Syntax Following is the syntax − public static char ToChar(string val, IFormatProvider provider); Parameters val − A string of length 1 or null. provider − An object that supplies culture-specific formatting information. This parameter is ignored for string-to-char conversion. Return Value Returns a Unicode character ...

Read More
Showing 11151–11160 of 61,297 articles
Advertisements