[RESOLVED] Storing DateTime settings in a class?
Hey guys,
I thought I understood storing variables I will be calling frequently into classes down pat, but this just isn't playing nicely.
Code:
Class Paramaters
{
Public DateTime time = DateTime.Now;
public string formatDate = "MM/dd";
}
The purpose is because I have a TON of if statements that will use this same call here and if I ever want to change it I don't want to have to go through each one to alter it. I know I can do it in a seperate class, but I am failing here. One thing I think my problem is, is that I am calling a class, within a class maybe? I don't see a way around this. Here is how I am trying to call it
Code:
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Text = Parameters.time.ToString(Parameters.formatDate);
}
Seems too simple to be true. Thanks for the help.
Re: [RESOLVED] Storing DateTime settings in a class?
Class:
public static class Paramaters
{
public const string MonthDayFormat = "MM/dd";
public static DateTime Time
{
get { return DateTime.Now; }
}
}
Call:
textBox1.Text = Paramaters.Time.ToString(Paramaters.MonthDayFormat);
Re: [RESOLVED] Storing DateTime settings in a class?
Re: [RESOLVED] Storing DateTime settings in a class?
I was in a pinch for time so I couldn't elaborate on why I resolved this. I was able to do what I describe why it is fixed.
It now pulls my requirements from my helper class and displays it in real time as intended. I just had my layout very much incorrect. I'm all about having less code in my main form and dealing with multiple classes instead. :)