Solved

C# -- Today's Date ?

Posted on 2009-07-10
2
2,419 Views
Last Modified: 2012-05-07
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
Comment
Question by:finance_teacher
2 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24827677
you have 1 quote too much at the end
0
 
LVL 6

Accepted Solution

by:
nandithaa earned 500 total points
ID: 24838301
private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Today is " + DateTime.Today.ToString("D"));
        }
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now