Programming Articles

Page 824 of 2547

What are reference data types in C#?

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

The reference data types in C# do not store the actual data directly in a variable, but instead contain a reference (or pointer) to the memory location where the data is stored. When you assign a reference type variable to another variable, both variables point to the same object in memory. In C#, the following are the built-in reference types − Object Type The object type is the ultimate base class for all data types in C# Common Type System (CTS). Object variables can be assigned values of any other types, whether value types, reference types, predefined, ...

Read More

C# Program to get the name of root directory

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

Use the RootDirectory property to get the name of the root directory of a drive in C#. This property belongs to the DriveInfo class and returns a DirectoryInfo object representing the root directory. Syntax Following is the syntax for getting the root directory − DriveInfo driveInfo = new DriveInfo("driveLetter"); DirectoryInfo rootDir = driveInfo.RootDirectory; Using DriveInfo.RootDirectory Property First, create a DriveInfo object to specify the drive for which you want the root directory − DriveInfo dInfo = new DriveInfo("C"); Then, the RootDirectory property gives you the root directory − ...

Read More

C# Program to find the cube of elements in a list

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

This program demonstrates how to find the cube of each element in a list using the Select() method with a lambda expression. The Select() method transforms each element in the collection by applying a specified function. Syntax Following is the syntax for using Select() method with lambda expression − collection.Select(x => expression) For calculating the cube of each element − list.Select(x => x * x * x) Using Select() Method to Calculate Cube The Select() method applies a transformation function to each element in the list. In this case, ...

Read More

DateTime.AddMinutes() Method in C#

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

The DateTime.AddMinutes() method in C# is used to add the specified number of minutes to the value of a DateTime instance. It returns a new DateTime object representing the calculated time without modifying the original instance. Syntax Following is the syntax − public DateTime AddMinutes(double minutes); Parameters minutes − A double value representing the number of minutes to add. The value can be positive (to add minutes) or negative (to subtract minutes). Fractional values are allowed. Return Value Returns a new DateTime object whose value is the sum of the date ...

Read More

C# Example for Single Inheritance

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

Single inheritance in C# allows a derived class to inherit from only one base class. This is the most common form of inheritance where a child class extends the functionality of its parent class by inheriting all accessible members and adding its own specific methods or properties. Syntax Following is the syntax for single inheritance in C# − class BaseClass { // base class members } class DerivedClass : BaseClass { // derived class members // inherits all accessible members from BaseClass } ...

Read More

Where do we use scope Resolution Operator (::) in C#?

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

The scope resolution operator (::) in C# is used to access types within namespaces, especially when dealing with namespace aliases or when there are naming conflicts. Unlike C++ where it's primarily used for global variables, in C# it specifically relates to namespace resolution. The scope resolution operator helps distinguish between types that share the same name but exist in different namespaces. It's particularly useful when using namespace aliases or the global keyword. Syntax Following is the syntax for using the scope resolution operator with namespace aliases − alias::TypeName Following is the syntax for ...

Read More

Get the drive format in C#

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

The DriveFormat property in C# is used to get the file system format of a drive. It returns a string representing the format type such as NTFS, FAT32, or exFAT for Windows systems. Syntax Following is the syntax for using the DriveFormat property − DriveInfo driveInfo = new DriveInfo(driveLetter); string format = driveInfo.DriveFormat; Parameters driveLetter − A string representing the drive letter (e.g., "C", "D", "E"). Return Value The DriveFormat property returns a string containing the name of the file system, such as "NTFS", "FAT32", or "exFAT". ...

Read More

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 165 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
Showing 8231–8240 of 25,466 articles
« Prev 1 822 823 824 825 826 2547 Next »
Advertisements