What is the difference between defining a value for a parameter? I assume setting it as const assigns it a value and its value cannot be changed. Assigning it as static assigns it a value that can be changed. But what does the third method allow that the others do not. Why define it this way? I am still learning C# and trying to adopt best practices. In this case I have a section of code that will instantiate these as global variables to be used throughout the entire application.
public const DateTime ApplyDate = Convert.ToDateTime("1900-01-01 00:00:00.000");
public static DateTime ApplyDate = Convert.ToDateTime("1900-01-01 00:00:00.000");
static public DateTime ApplyDate
{
get { return Convert.ToDateTime("1900-01-01 00:00:00.000"); }
}
Our community of experts have been thoroughly vetted for their expertise and industry experience.