hello world in csharp

Here's a simple Hello World program in C# using Visual Studio IDE:

main.cs
using System;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Hello World!");
    }
}
124 chars
10 lines

Alternatively, you can use .NET Core command line to create a console application and run the program using the following steps:

  1. Open a terminal or command prompt.
  2. Create a new console application project using dotnet new console.
  3. Navigate to the project directory using cd <project-name>.
  4. Open the Program.cs file in a text editor, such as Visual Studio Code.
  5. Replace the contents of the file with the following code:
main.cs
using System;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Hello World!");
    }
}
124 chars
10 lines
  1. Save the file and run the program using dotnet run. You should see Hello World! printed in the terminal.

gistlibby LogSnag