The Woo
The Woo

Reputation: 18645

C# Set String To Current Date +1

I have a string called "dayofweektext".

What I need to do is change the value of this to the current date, plus one day. IE: If the user inputs "tomorrow", I want to use something like (DayOfWeek day) +1 to set "dayofweektext" to tomorrows day name.

This is what I have currently, but it isn't working and I haven't used the (DayOfWeek) successfully before:

if (dayofweektext.Contains("tomorrow"))
{
   dayofweektext = (DayOfWeek day) + 1;
}

Upvotes: 0

Views: 224

Answers (1)

Agustin Meriles
Agustin Meriles

Reputation: 4854

Why don't

if (dayofweektext.Contains("tomorrow"))
{
    dayofweektext = DateTime.Today.AddDays(1).DayOfWeek.ToString();
}

Upvotes: 4

Related Questions