• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2432
  • Last Modified:

C# -- Today's Date ?

How can I get the "ISSUE #1" section
to work in ONE line without having
to create a "string today =....." VAR ?
--------------------------------------------
WORKS #1

      private void button1_Click(object sender, EventArgs e)
      {
          string today = String.Format("Today is {0}", DateTime.Today.ToString("D"));
          MessageBox.Show(today);
      }
--------------------------------------------
WORKS #2

      private void button1_Click(object sender, EventArgs e)
      {
          string today = "Today is " + DateTime.Today.ToString("D");
          MessageBox.Show(today);
      }
--------------------------------------------
ISSUE #1

      private void button1_Click(object sender, EventArgs e)
      {
          MessageBox.Show("Today is " + DateTime.Today.ToString("D")");
      }
0
finance_teacher
Asked:
finance_teacher
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you have 1 quote too much at the end
0
 
nandithaaCommented:
private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Today is " + DateTime.Today.ToString("D"));
        }
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now