Server Side Programming Articles

Page 825 of 2109

C# Program to get current day of week

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 16K+ Views

Use the DateTime.DayOfWeek property to get the current day of the week in C#. This property returns a DayOfWeek enumeration value representing the day. Syntax Following is the syntax to get the current day of the week − DayOfWeek dayOfWeek = DateTime.Today.DayOfWeek; You can also use DateTime.Now.DayOfWeek to include the current time − DayOfWeek dayOfWeek = DateTime.Now.DayOfWeek; Using DateTime.Today.DayOfWeek The DateTime.Today property gets the current date with the time component set to 00:00:00. Using DayOfWeek on this returns the current day as an enumeration value − using ...

Read More

Generate current month in C#

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

To generate the current month in C#, you can use the DateTime.Now property to get the current date and time, then extract the month information using various properties and formatting methods. Syntax Following is the syntax to get the current date − DateTime dt = DateTime.Now; Following is the syntax to get the month as a number − int month = dt.Month; Following is the syntax to get the month name using formatting − string monthName = dt.ToString("MMMM"); Getting Current Month as Number The Month ...

Read More

How to initialize an empty DateTime in C#

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

In C#, there are several ways to initialize an empty or default DateTime value. The most common approach is using DateTime.MinValue, which represents the minimum possible date and time value in the .NET framework. Syntax Following are the different ways to initialize an empty DateTime − DateTime dt1 = DateTime.MinValue; DateTime dt2 = new DateTime(); DateTime dt3 = default(DateTime); Using DateTime.MinValue The DateTime.MinValue property returns the minimum possible DateTime value, which is January 1, 0001 at 12:00:00 AM − using System; public class Demo { public static ...

Read More

C# General Date Short Time ("g") Format Specifier

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

The General Date Short Time ("g") format specifier in C# is a standard DateTime format that combines the short date pattern ("d") and short time pattern ("t"), separated by a space. This format provides a compact representation of both date and time information. Syntax Following is the syntax for using the "g" format specifier − dateTime.ToString("g") dateTime.ToString("g", CultureInfo) The format pattern varies based on the current culture or specified culture. It typically displays − Short date − MM/dd/yyyy or dd/MM/yyyy depending on culture Short time − HH:mm or h:mm tt (12-hour with ...

Read More

C# DateTime Max Value

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

The DateTime.MaxValue property in C# returns the maximum possible value for a DateTime object. This represents the largest date and time that can be stored in a DateTime structure, which is December 31, 9999 at 11:59:59.9999999 PM. This property is useful when you need to initialize a DateTime variable with the highest possible value, compare dates to find the maximum, or set upper bounds in date range validations. Syntax Following is the syntax for accessing the maximum DateTime value − DateTime maxValue = DateTime.MaxValue; DateTime MaxValue Example The following example demonstrates how ...

Read More

C# Program to return specified number of elements from the end of an array

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

The TakeLast() method in C# returns a specified number of elements from the end of a sequence. It's part of the LINQ library and provides an efficient way to extract the last few elements from arrays, lists, or other enumerable collections. Syntax Following is the syntax for using TakeLast() − IEnumerable TakeLast(int count) Parameters count − The number of elements to return from the end of the sequence. Return Value Returns an IEnumerable containing the specified number of elements from the end of the source sequence. Using TakeLast() ...

Read More

C# TimeSpan Min value

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

The TimeSpan structure in C# represents a time interval or duration. The TimeSpan.MinValue property returns the minimum possible value that a TimeSpan can represent, which is approximately -10.7 million days. This minimum value is useful when you need to initialize a TimeSpan variable to the smallest possible value or when performing comparisons to find the minimum time span in a collection. Syntax Following is the syntax to access the minimum TimeSpan value − TimeSpan.MinValue Return Value The TimeSpan.MinValue property returns a TimeSpan object representing the minimum possible time interval, which equals approximately ...

Read More

C# TimeSpan Max value

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 1K+ Views

The TimeSpan structure in C# represents a time interval or duration. The TimeSpan.MaxValue property returns the maximum possible value that a TimeSpan can represent. Syntax Following is the syntax to get the maximum TimeSpan value − TimeSpan.MaxValue Return Value The MaxValue property returns a TimeSpan object representing the maximum time span value, which is approximately 10.7 million days or about 29, 227 years. TimeSpan.MaxValue Breakdown 10675199.02:48:05.4775807 Days: 10, 675, 199 Hours: 02 ...

Read More

C# Program to get the absolute value of the time

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

To get the absolute value of time, use the TimeSpan.Duration()

Read More

C# Console BufferHeight Property

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

The Console.BufferHeight property in C# gets or sets the height of the buffer area in rows. The buffer height represents the maximum number of text rows that can be stored in the console's internal buffer before older lines are discarded. This property is particularly useful when you need to control how much output history the console retains or when working with console applications that produce large amounts of output. Syntax Following is the syntax for using the BufferHeight property − // Get buffer height int height = Console.BufferHeight; // Set buffer height Console.BufferHeight = ...

Read More
Showing 8241–8250 of 21,090 articles
« Prev 1 823 824 825 826 827 2109 Next »
Advertisements