Articles on Trending Technologies

Technical articles with clear explanations and examples

How is an array initialized in C#?

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

All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element. In C#, arrays must be properly initialized before you can use them to store and access data. Array Declaration vs Initialization Firstly, declare an array − int[] rank; But declaring an array does not initialize the array in the memory. When the array variable is initialized, you can assign values to the array. Array is a reference type, so you need to use the new keyword to create an instance ...

Read More

What are virtual functions in C#?

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

The virtual keyword in C# allows a method, property, indexer, or event to be overridden in derived classes. Virtual functions enable runtime polymorphism, where the actual method called is determined at runtime based on the object's type, not the reference type. When you define a virtual function in a base class, derived classes can provide their own implementations using the override keyword. This allows different derived classes to implement the same method differently while maintaining a common interface. Syntax Following is the syntax for declaring a virtual method − public virtual returnType MethodName() { ...

Read More

C# Linq Reverse Method

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

The LINQ Reverse() method in C# is used to reverse the order of elements in a sequence. It returns a new sequence with elements in reverse order without modifying the original collection. Syntax Following is the syntax for the LINQ Reverse() method − public static IEnumerable Reverse( this IEnumerable source ) Parameters source: The sequence of values to reverse. It must implement IEnumerable. Return Value The Reverse() method returns an IEnumerable whose elements correspond to those of the input sequence in reverse order. ...

Read More

CharEnumerator.Reset() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 152 Views

The CharEnumerator.Reset() method in C# initializes the enumerator's position to logically before the first character of the enumerated string. This method is useful when you need to restart enumeration from the beginning after having already iterated through the string. Syntax Following is the syntax for the CharEnumerator.Reset() method − public void Reset(); Parameters This method takes no parameters. Return Value This method does not return any value (void). How It Works When you call Reset(), the enumerator's internal position is moved to before the first character. After calling Reset(), ...

Read More

C# program to check if string is panagram or not

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

A pangram is a sentence that contains all 26 letters of the English alphabet at least once. The word "pangram" comes from Greek, meaning "all letters". A famous example is "The quick brown fox jumps over the lazy dog". In C#, we can check if a string is a pangram by converting it to lowercase, filtering only alphabetic characters, and counting the distinct letters present. Syntax The basic approach uses LINQ methods to process the string − string.ToLower().Where(ch => Char.IsLetter(ch)).GroupBy(ch => ch).Count() This checks if the count of distinct letters equals 26. ...

Read More

C# Program to Implement Stack with Push and Pop operations

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

A Stack in C# is a Last-In-First-Out (LIFO) data structure that allows elements to be added and removed from only one end, called the top. The Stack class in the System.Collections namespace provides built-in methods for implementing stack operations. The two primary operations of a stack are Push() to add elements and Pop() to remove elements. Additionally, the Peek() method allows you to view the top element without removing it. Syntax Following is the syntax for creating a Stack and using basic operations − Stack stackName = new Stack(); stackName.Push(element); // ...

Read More

StringWriter vs StringReader in C#?

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

StringReader and StringWriter are classes in C# that derive from TextReader and TextWriter respectively. They provide convenient ways to read from and write to strings as if they were streams or files. StringWriter is used for writing data into a string buffer, while StringReader is used for reading data from a string. Both classes are particularly useful when working with APIs that expect TextReader or TextWriter objects. StringWriter Class StringWriter implements a TextWriter for writing information to a string. It maintains an internal StringBuilder that accumulates the written content. Syntax StringWriter writer = new ...

Read More

C# Program to get free space in a drive

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

To get the free space in a drive, use the AvailableFreeSpace and TotalFreeSpace properties of the DriveInfo class in C#. This is useful for monitoring disk space and making decisions based on available storage. Syntax Following is the syntax for creating a DriveInfo object and accessing free space properties − DriveInfo driveInfo = new DriveInfo("DriveLetter"); long availableSpace = driveInfo.AvailableFreeSpace; long totalFreeSpace = driveInfo.TotalFreeSpace; Properties Property Description AvailableFreeSpace Gets the amount of available free space on a drive, in bytes, available to the current user. ...

Read More

C# Console BufferWidth Property

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

The Console.BufferWidth property in C# gets or sets the width of the buffer area in columns. The buffer area is the region of memory that stores console output before it's displayed on the screen. This property is particularly useful when you need to control the console display width programmatically. Syntax Following is the syntax for getting the buffer width − int width = Console.BufferWidth; Following is the syntax for setting the buffer width − Console.BufferWidth = value; Return Value The property returns an int representing the width of the ...

Read More

Math.Sinh() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 127 Views

The Math.Sinh() method in C# calculates the hyperbolic sine of a specified angle in radians. The hyperbolic sine function is defined mathematically as (ex - e-x)/2, where e is Euler's number (approximately 2.71828). This method is commonly used in mathematical calculations involving hyperbolic functions, engineering applications, and scientific computations. Syntax Following is the syntax of the Math.Sinh() method − public static double Sinh(double value) Parameters value: A double-precision floating-point number representing an angle in radians for which the hyperbolic sine is to be calculated. Return Value Returns a double representing ...

Read More
Showing 10891–10900 of 61,297 articles
Advertisements