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
Server Side Programming Articles
Page 831 of 2109
Represent Int32 as a Octal String in C#
To represent Int32 as an octal string in C#, use the Convert.ToString() method with base 8 as the second parameter. An Int32 represents a 32-bit signed integer that can hold values from -2, 147, 483, 648 to 2, 147, 483, 647. Syntax Following is the syntax for converting an Int32 to octal string − Convert.ToString(intValue, 8) Parameters intValue − The integer value to convert. 8 − The base for octal representation. Return Value The method returns a string representing the integer in octal format (base ...
Read MoreC# Orderby Descending
The orderby descending clause in C# is used with LINQ to sort collections in descending order. It works with both query syntax and method syntax, allowing you to sort objects by any property or field. Syntax Following is the syntax for using orderby descending with LINQ query syntax − var result = from item in collection orderby item.Property descending select item; Following is the syntax for ...
Read MoreImplicit conversion from 16-bit unsigned integer (ushort) to Decimal in C#
ushort represents a 16-bit unsigned integer in C# with a range from 0 to 65, 535. C# allows implicit conversion from ushort to decimal because this conversion is always safe and does not result in data loss. The decimal type can accommodate the entire range of ushort values without precision loss, making implicit conversion possible. Syntax Following is the syntax for implicit conversion from ushort to decimal − ushort ushortValue = value; decimal decimalValue = ushortValue; // implicit conversion How It Works The conversion happens automatically without requiring explicit casting or ...
Read MoreFull Date Long Time ("F") Format Specifier in C#
The Full Date Long Time ("F") format specifier in C# displays a complete date and time representation in a long format. This format specifier uses the current culture's DateTimeFormatInfo.FullDateTimePattern property to determine the exact format string. The "F" specifier provides the most comprehensive date and time display, showing the full day name, complete date, and precise time including seconds. Syntax Following is the syntax for using the "F" format specifier − DateTime.ToString("F") DateTime.ToString("F", CultureInfo) The default custom format string for "F" is − dddd, dd MMMM yyyy HH:mm:ss Using ...
Read MoreC# 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 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 MoreC# Program to find the cube of elements in a list
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 MoreC# Linq Select Method
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 MoreC# Linq SelectMany Method
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 MoreC# Queryable SequenceEqual() Method
The SequenceEqual() method in C# is used to determine whether two sequences are equal by comparing elements in the same position. This method returns true if both sequences contain the same elements in the same order, otherwise it returns false. The method is part of the System.Linq namespace and can be used with IQueryable collections to perform element-by-element comparison. Syntax Following is the syntax for the SequenceEqual() method − public static bool SequenceEqual( this IQueryable source1, IEnumerable source2 ) With custom comparer − ...
Read More