[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
VisualCSharpHelloWorldConsole

(C#) Hello World in Visual C#,  ?Console Application

  • 'File | Close Solution'
  • 'File | New Project | Console Application'
Now a default Console Application is created. The following code appears:

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
        }
    }
}


Add one line to change it to the following code:

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Console.WriteLine("Hello world");
        }
    }
}


Run the program with 'Debug | Start without debugging' (or CTRL-F5).

You can also run it with 'Debug | Start debugging', but then the window with text will immediately disappear after putting 'Hello World' on the screen.

To solve this, add one more line, making the code like this:

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Console.WriteLine("Hello world");
            System.Console.ReadKey();
        }
    }
}




last edited (April 9, 2007) by bilderbikkel, Number of views: 678, Current Rev: 2 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.