User FAQs

If you have a question, please send it to us.


1) Can you have a DateTime Literal constant in C# ?
C# does not support date or time literal constants (however VB.Net does).
A date and time literal constant must be declared using the System.DateTime class.

System.DateTime myDate = new System.DateTime(1900, 1, 1); 

2) How can I display todays date in a particular format ?
There are lots of different ways.

System.DateTime myDate = System.DateTime.Now.ToString("dd-MMM-yyyy"); 
System.DateTime myDate = System.String.Format("{0:MM\/dd\/yyyy}", System.DateTime.Now);

3) Is System.DateTime.Now a local time or UTC ?



4) Is it possible to declare a DateTime variable as a constant ?
Yes. You must use "static readonly" instead of "const"

public static readonly int CURRENT_YEAR = System.DateTime.Now.Year; 


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext