Server Side Programming Articles

Page 824 of 2109

C# Fixed-Point ("F") Format Specifier

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

The Fixed-Point ("F") format specifier in C# converts a number to a string with a fixed number of decimal places. It produces output in the form "-ddd.ddd..." where "d" represents a digit (0-9). The negative sign appears only for negative numbers. Syntax Following is the syntax for using the Fixed-Point format specifier − number.ToString("F") // Default 2 decimal places number.ToString("Fn") // n decimal places (0-99) number.ToString("F", culture) // With specific culture Default Precision When no precision ...

Read More

C# Percent ("P") Format Specifier

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

The percent ("P") format specifier in C# is used to format numbers as percentages. It multiplies the number by 100 and appends a percentage sign (%) to create a string representation of the percentage value. Syntax Following is the syntax for using the percent format specifier − number.ToString("P") // Default precision (2 decimal places) number.ToString("Pn") // Specify n decimal places Where n represents the number of decimal places to display after the decimal point. How It Works The percent ...

Read More

C# Program to determine the difference in hours between two dates

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

In C#, you can calculate the difference in hours between two dates using the DateTime structure and the TimeSpan class. The TimeSpan represents a time interval and provides properties to get the difference in various units including hours. Syntax Following is the syntax for calculating the time difference − DateTime date1 = new DateTime(year, month, day, hour, minute, second); DateTime date2 = new DateTime(year, month, day, hour, minute, second); TimeSpan difference = date2 - date1; double hours = difference.TotalHours; Using DateTime Subtraction The most straightforward way to find the difference in hours is ...

Read More

C# Program to add a node after the given node in a Linked List

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

A LinkedList in C# is a doubly linked list that allows efficient insertion and removal of elements at any position. The AddAfter() method inserts a new node immediately after a specified existing node in the list. Syntax Following is the syntax for the AddAfter() method − public LinkedListNode AddAfter(LinkedListNode node, T value) Parameters node − The LinkedListNode after which to insert a new node containing value. value − The value to add to the LinkedList. Return Value The method returns the new LinkedListNode containing the ...

Read More

C# Console.WindowHeight Property

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

The Console.WindowHeight property in C# gets or sets the height of the console window measured in rows. This property allows you to retrieve the current console window height or modify it programmatically to control the display area of your console application. Syntax Following is the syntax for getting the window height − int height = Console.WindowHeight; Following is the syntax for setting the window height − Console.WindowHeight = newHeight; Return Value The property returns an int value representing the height of the console window in rows. When setting, it ...

Read More

C# Program to get the difference between two dates in seconds

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

In C#, you can calculate the difference between two dates in seconds using the TimeSpan structure. When you subtract one DateTime from another, it returns a TimeSpan object that represents the time interval between them. Syntax Following is the syntax for calculating date difference in seconds − DateTime date1 = new DateTime(year, month, day, hour, minute, second); DateTime date2 = new DateTime(year, month, day, hour, minute, second); TimeSpan difference = date2 - date1; double seconds = difference.TotalSeconds; Using DateTime Subtraction The most straightforward approach is to subtract one DateTime from another, which returns ...

Read More

Calculate minutes between two dates in C#

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

Calculating the difference in minutes between two dates is a common requirement in C# applications. The DateTime structure and TimeSpan class provide built-in functionality to perform this calculation efficiently. Syntax Following is the basic syntax for calculating minutes between two dates − DateTime date1 = new DateTime(year, month, day, hour, minute, second); DateTime date2 = new DateTime(year, month, day, hour, minute, second); TimeSpan difference = date2 - date1; double minutes = difference.TotalMinutes; How It Works When you subtract one DateTime from another, C# returns a TimeSpan object that represents the time difference. The ...

Read More

C# Console.WindowLeft Property

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

The Console.WindowLeft property in C# gets or sets the leftmost position of the console window area relative to the screen buffer. This property is useful when you need to control or retrieve the horizontal position of the console window within the buffer area. Syntax Following is the syntax to get the left position of the console window − int position = Console.WindowLeft; Following is the syntax to set the left position of the console window − Console.WindowLeft = value; Return Value The property returns an int value representing the ...

Read More

C# difference in milliseconds between two DateTime

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

In C# programming, you often need to calculate the time difference between two DateTime objects. The most efficient way to get the difference in milliseconds is by using the TimeSpan structure and its TotalMilliseconds property. Syntax Following is the syntax for calculating milliseconds difference between two DateTime objects − DateTime date1 = new DateTime(year, month, day, hour, minute, second); DateTime date2 = new DateTime(year, month, day, hour, minute, second); TimeSpan difference = date2 - date1; double milliseconds = difference.TotalMilliseconds; Using TimeSpan to Calculate Milliseconds Difference When you subtract one DateTime from another, the ...

Read More

C# Program to check whether the elements of a sequence satisfy a condition or not

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

The All() method in C# is used to check whether all elements in a sequence satisfy a specified condition. This method returns true only if every element meets the condition; if even one element fails the condition, it returns false. The All() method is part of LINQ (Language Integrated Query) and can be used with arrays, lists, and other enumerable collections. It uses lambda expressions to define the condition that each element must satisfy. Syntax Following is the syntax for using the All() method − bool result = collection.All(predicate); Where predicate is a ...

Read More
Showing 8231–8240 of 21,090 articles
« Prev 1 822 823 824 825 826 2109 Next »
Advertisements