Articles on Trending Technologies

Technical articles with clear explanations and examples

C# Linq Select Method

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

The Select method in C# LINQ is used to transform each element of a collection into a new form. It projects each element of a sequence into a new sequence by applying a transformation function to each element. Syntax Following is the basic syntax for the Select method − public static IEnumerable Select( this IEnumerable source, Func selector ) The overload with index parameter − public static IEnumerable Select( this IEnumerable source, Func selector ) Parameters ...

Read More

Math.Tanh() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 166 Views

The Math.Tanh() method in C# returns the hyperbolic tangent of a specified angle. The hyperbolic tangent function is commonly used in mathematical calculations, especially in calculus and engineering applications. Unlike the regular tangent function which deals with circular trigonometry, the hyperbolic tangent operates on hyperbolic angles. Syntax Following is the syntax for the Math.Tanh() method − public static double Tanh(double value); Parameters The method accepts the following parameter − value − A double representing the angle in radians for which to calculate the hyperbolic tangent. Return Value ...

Read More

Type.GetMember() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 294 Views

The Type.GetMember() method in C# is used to retrieve information about specified members of the current Type using reflection. It returns an array of MemberInfo objects that represent the members matching the specified name and binding criteria. Syntax Following are the syntax variations for the Type.GetMember() method − public System.Reflection.MemberInfo[] GetMember(string name); public virtual System.Reflection.MemberInfo[] GetMember(string name, System.Reflection.BindingFlags bindingAttr); Parameters name − A string specifying the name of the member to search for. bindingAttr − A combination of BindingFlags values that control how the search is conducted. ...

Read More

Why do we use comma operator in C#?

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

The comma operator in C# serves as a separator and allows multiple operations within a single statement. It is most commonly used in for loops for multiple variable initialization and increment operations, and as a separator in method parameter lists. Syntax Following is the syntax for using comma operator in for loop initialization and increment − for (int i = value1, j = value2; condition; i++, j++) { // loop body } Following is the syntax for using comma as separator in method parameters − MethodName(parameter1, parameter2, parameter3); ...

Read More

What is the base class for all exceptions in C#?

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

In C#, the base class for all exceptions is System.Exception. This is the root class from which all exception types derive, providing a common structure and functionality for error handling throughout the .NET framework. The System.Exception class has two primary derived classes: System.SystemException for system-generated exceptions and System.ApplicationException for application-specific exceptions. However, Microsoft now recommends deriving custom exceptions directly from System.Exception or its appropriate subclasses rather than from System.ApplicationException. Exception Hierarchy C# Exception Hierarchy System.Exception System.SystemException ...

Read More

Get all drives in C#

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

In C#, you can retrieve information about all drives on a system using the DriveInfo.GetDrives() method. This method returns an array of DriveInfo objects representing all logical drives on the current system, including hard drives, network drives, CD-ROMs, and other storage devices. Syntax Following is the syntax for getting all drives − DriveInfo[] drives = DriveInfo.GetDrives(); To iterate through the drives and access their properties − foreach (DriveInfo drive in drives) { Console.WriteLine(drive.Name); } Using GetDrives() to Display Drive Names The simplest approach is to get ...

Read More

C# Linq SelectMany Method

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

The SelectMany method in C# LINQ is used to flatten collections of collections into a single sequence. It projects each element of a sequence to an IEnumerable and then flattens the resulting sequences into one sequence. Syntax Following is the basic syntax for SelectMany method − public static IEnumerable SelectMany( this IEnumerable source, Func selector ) Parameters source − The input sequence to transform. selector − A function that transforms each element into a collection. Return Value Returns an IEnumerable whose ...

Read More

How is an array declared in C#?

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

To declare an array in C#, you specify the data type followed by square brackets and the array name. Arrays in C# are reference types that store multiple elements of the same data type in a contiguous memory location. Syntax Following is the basic syntax for declaring an array − datatype[] arrayName; To declare and initialize an array with a specific size − datatype[] arrayName = new datatype[size]; To declare and initialize an array with values − datatype[] arrayName = {value1, value2, value3, ...}; Here − ...

Read More

Try-Catch-Finally in C#

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

The try-catch-finally statement in C# provides a structured way to handle exceptions that may occur during program execution. It allows you to gracefully handle errors like division by zero, file access failures, or network timeouts without crashing your application. Exception handling in C# is performed using three main keywords that work together to create a robust error handling mechanism. Syntax Following is the basic syntax of try-catch-finally statement − try { // Code that may throw an exception } catch (ExceptionType ex) { // Handle the exception } finally ...

Read More

TakeWhile method in C# ()

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

The TakeWhile() method in C# is a LINQ extension method that returns elements from the beginning of a sequence as long as a specified condition is true. It stops immediately when the first element that doesn't satisfy the condition is encountered, even if later elements might satisfy the condition. Syntax Following is the syntax for the TakeWhile() method − public static IEnumerable TakeWhile( this IEnumerable source, Func predicate ) Parameters source − The sequence to return elements from. predicate − ...

Read More
Showing 10911–10920 of 61,297 articles
Advertisements