Articles on Trending Technologies

Technical articles with clear explanations and examples

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 is unmanaged code in C#?

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

Unmanaged code in C# refers to code that executes outside the control of the .NET Common Language Runtime (CLR). This type of code is also known as unsafe code because it bypasses many of the safety mechanisms that make C# a managed language. In C#, unmanaged code typically involves the use of pointers and direct memory manipulation, similar to languages like C and C++. To use unmanaged code, you must explicitly mark code blocks with the unsafe keyword. Key Characteristics of Unmanaged Code Applications that are not under the control of the CLR are unmanaged. ...

Read More

C# program to create a List with elements from an array

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

In C#, you can easily create a List with elements from an existing array. The List constructor accepts an IEnumerable parameter, which allows you to initialize the list directly with array elements. Syntax Following is the syntax to create a list from an array − List listName = new List(arrayName); You can also use the ToList() extension method − List listName = arrayName.ToList(); Using List Constructor The most straightforward way is to pass the array directly to the List constructor − using System; using System.Collections.Generic; public ...

Read More

Math.Exp() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 364 Views

The Math.Exp() method in C# returns e (Euler's number, approximately 2.718) raised to the specified power. This method is commonly used in mathematical calculations involving exponential functions, growth calculations, and scientific computations. Syntax Following is the syntax for the Math.Exp() method − public static double Exp(double d) Parameters d − A double-precision floating-point number representing the power to which e is raised. Return Value Returns a double value representing ed. Special cases include: If d equals Double.NaN, the method returns NaN. If ...

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

Flow control in try catch finally in C#

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

The flow control in try-catch-finally blocks in C# follows a specific execution order depending on whether exceptions occur. Understanding this flow is crucial for proper error handling and resource management in your applications. Syntax Following is the syntax for try-catch-finally blocks − try { // Code that may throw an exception } catch (ExceptionType e) { // Exception handling code } finally { // Code that always executes } Flow Control Rules The try block executes first and contains code that might ...

Read More

C# program to find the index of an element in a List

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

In C#, you can find the index of an element in a List using the IndexOf() method. This method returns the zero-based index of the first occurrence of the specified element, or -1 if the element is not found. Syntax Following is the syntax for the IndexOf() method − int IndexOf(T item) int IndexOf(T item, int startIndex) int IndexOf(T item, int startIndex, int count) Parameters item: The element to locate in the list. startIndex: The zero-based starting index of the search (optional). count: The number of elements to search (optional). ...

Read More

C# Program to rename a file

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

In C#, you can rename a file using the File.Move() method from the System.IO namespace. This method moves a file from one location to another, and when the source and destination paths are in the same directory with different filenames, it effectively renames the file. Syntax Following is the syntax for renaming a file using File.Move() − File.Move(string sourceFileName, string destFileName); Parameters sourceFileName − The current path and name of the file to rename. destFileName − The new path and name for the file. Using File.Move() to Rename Files ...

Read More

Math.Floor() Method in C#

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

The Math.Floor() method in C# returns the largest integral value that is less than or equal to the specified number. It rounds down to the nearest integer, which is particularly important to understand when working with negative numbers. Syntax The Math.Floor() method has two overloads − public static decimal Floor(decimal val); public static double Floor(double val); Parameters val − A decimal or double number to be rounded down to the nearest integer. Return Value Returns the largest integer less than or equal to val. The return type ...

Read More

Boolean.CompareTo(Object) Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 169 Views

The Boolean.CompareTo(Object) method in C# compares the current Boolean instance to a specified object and returns an integer that indicates their relationship to one another. This method is useful for sorting Boolean values or implementing custom comparison logic. Syntax Following is the syntax − public int CompareTo(object obj); Where obj is an object to compare to this instance, or null. Return Value The method returns an integer value indicating the relationship between the current instance and the specified object − Less than zero: This instance is false and obj is ...

Read More
Showing 10691–10700 of 61,297 articles
Advertisements