Solved

C# -- Today's Date ?

Posted on 2009-07-10
2
2,422 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Calculate number of nights between two dates 5 91
Return array 3 20
Nested forach loop to linq 3 27
Java pass by reference 3 19
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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