Server Side Programming Articles

Page 775 of 2109

What are generic collections in C#?

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

Generic collections in C# are type-safe collections that allow you to specify the type of elements at compile time. They provide better performance, type safety, and IntelliSense support compared to non-generic collections like ArrayList and Hashtable. The most commonly used generic collections include List, Dictionary, SortedList, Queue, and Stack. These are part of the System.Collections.Generic namespace. Syntax Following is the syntax for declaring generic collections − List listName = new List(); Dictionary dictName = new Dictionary(); SortedList sortedListName = new SortedList(); Where T, TKey, and TValue are type parameters that specify the actual ...

Read More

What are generic delegates in C#?

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

Generic delegates in C# allow you to create delegate types with type parameters, providing flexibility to work with different data types without defining separate delegate declarations for each type. The .NET Framework provides several built-in generic delegates in the System namespace that eliminate the need for custom delegate definitions in most scenarios. Syntax Following is the syntax for declaring a custom generic delegate − delegate TResult DelegateName(T parameter); Built-in generic delegates use these syntaxes − Action actionDelegate = method; // void return type Func funcDelegate = method; // ...

Read More

What are key-based I/O collections in C#?

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

Key-based I/O collections in C# are collections that store data as key-value pairs, where you can access values using their associated keys. The primary example of this is the SortedList class, which maintains elements in sorted order based on the keys. Syntax Following is the syntax for declaring a generic SortedList − SortedList listName = new SortedList(); Following is the syntax for adding key-value pairs − listName.Add(key, value); listName[key] = value; // alternative syntax Key Features of SortedList Stores key-value pairs sorted by keys in ascending order ...

Read More

What are identifiers in C#?

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

An identifier is a name used to identify a class, variable, function, or any other user-defined item in C#. Identifiers are fundamental building blocks that allow developers to name and reference different elements in their code. Rules for Naming Identifiers The basic rules for naming identifiers in C# are as follows − A name must begin with a letter or underscore that could be followed by a sequence of letters, digits (0-9), or underscores. The first character in an identifier cannot be a digit. It must not contain any embedded space or special ...

Read More

What are dynamic data types in C#?

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

The dynamic data type in C# allows you to store any type of value in a variable. Unlike other data types, type checking for dynamic variables occurs at runtime rather than compile-time, providing flexibility but requiring careful handling to avoid runtime errors. Syntax Following is the syntax for declaring a dynamic variable − dynamic = value; Basic Dynamic Variable Declaration Example using System; class Program { public static void Main() { dynamic val1 = 100; ...

Read More

Way to increment a character in C#

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

In C#, you can increment a character by using the increment operator ++. When you increment a character, it moves to the next character in the ASCII table sequence. Syntax Following is the syntax for incrementing a character − char ch = 'K'; ch++; // moves to next ASCII character You can also use the compound assignment operator − ch += 1; // equivalent to ch++ How It Works Characters in C# are stored as numeric values based on their ASCII or Unicode code points. When you ...

Read More

Ways to print escape characters in C#

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

The following are the escape characters in C# and the display column suggests how to use and print them in C# − Escape Character Description Pattern Display \a Matches a bell character, \u0007. \a "\u0007" in "Warning!" + '\u0007' \b In a character class, matches a backspace, \u0008. [\b]{3, } "\b\b\b\b" in "\b\b\b\b" \t Matches a tab, \u0009. (\w+)\t "Name\t", "Addr\t" in "Name\tAddr\t" \r Matches a carriage return, \u000D. (\r is not equivalent to the newline character, .) \r(\w+) "\rHello" in "\r\HelloWorld." \v Matches ...

Read More

Way to read input from console in C#

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

The Console.ReadLine() method is the primary way to read input from the console in C#. This method reads a complete line of text from the console and returns it as a string. Since all console input is received as text, you need to convert it to the appropriate data type when working with numbers or other non-string values. Syntax Following is the syntax for reading console input − string input = Console.ReadLine(); For converting string input to other data types − int number = Convert.ToInt32(input); ...

Read More

What are integer literals in C#?

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

An integer literal in C# is a constant numeric value written directly in the code. Integer literals can be decimal (base 10) or hexadecimal (base 16) constants. A prefix specifies the base: 0x or 0X for hexadecimal, with no prefix for decimal. They can also have suffixes like U for unsigned and L for long. Syntax Following is the syntax for different types of integer literals − // Decimal literals 123 200L // long 456U // unsigned int 789UL // unsigned long // Hexadecimal literals 0xFF ...

Read More

What are file operations in C#?

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

File operations in C# allow you to work with files and directories on the file system. These operations include creating, opening, reading, writing, appending, and deleting files. The System.IO namespace provides comprehensive classes and methods for file handling. The FileStream class is the primary class for file operations in C#. It provides low-level access to files and derives from the abstract Stream class. This class enables reading from, writing to, and closing files efficiently. Syntax To create a FileStream object, use the following syntax − FileStream fileStream = new FileStream(fileName, FileMode, FileAccess, FileShare); ...

Read More
Showing 7741–7750 of 21,090 articles
« Prev 1 773 774 775 776 777 2109 Next »
Advertisements