Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Programming Articles
Page 823 of 2547
C# Linq Reverse Method
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 MoreCharEnumerator.Reset() Method in C#
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 MoreC# program to check if string is panagram or not
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 MoreC# Program to Implement Stack with Push and Pop operations
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 MoreStringWriter vs StringReader in C#?
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 MoreC# Program to get free space in a drive
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 MoreC# Console BufferWidth Property
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 MoreMath.Sinh() Method in C#
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 MoreC# Program to get the name of the drive
The DriveInfo class in C# provides information about drives on the system. You can use the Name property to get the name of a specific drive by passing the drive letter to the DriveInfo constructor. Syntax Following is the syntax for creating a DriveInfo object and getting the drive name − DriveInfo info = new DriveInfo("driveLetter"); string driveName = info.Name; Parameters driveLetter − A string representing the drive letter (e.g., "C", "D", "E"). Return Value The Name property returns a string containing the name of the drive, ...
Read MoreDateTime.AddMilliseconds() Method in C#
The DateTime.AddMilliseconds() method in C# is used to add a specified number of milliseconds to a DateTime instance. This method returns a new DateTime object with the updated value, leaving the original DateTime unchanged. Syntax Following is the syntax − public DateTime AddMilliseconds(double value); Parameters value − A double representing the number of milliseconds to add. Can be positive or negative. Return Value Returns a new DateTime object whose value is the sum of the date and time represented by this instance and the number of milliseconds ...
Read More