Question

I am writing a text to speech program in C#, and have gotten the time information with the following code:

else if (e.KeyCode == Keys.Enter && InputTextbox.Text == "what time is it")
{
    OutputTextbox.Text = "The time is " + DateTime.Now.ToShortTimeString>();

    pBuilder.ClearContent();
    pBuilder.AppendText(OutputTextbox.Text);

    sSynth.Speak(pBuilder);

    e.SuppressKeyPress = true;
    InputTextbox.Text = "";
}

This gives me a value such as "The time is 11:01am".

Can someone please tell me a similar way to get the day of the week to return please?

Was it helpful?

Solution

Simply:

DateTime.Now.DayOfWeek.ToString();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top