about
Bits Hello C#
11/17/2023
0
Bits: Hello C#
code, output, and build for C# on Windows, macOS, and Linux
Synopsis:
This page demonstrates use of Visual Studio Code to build and execute a simple C# "Hello World" program, showing its build process and launch file. The purpose is to show how to get started quickly.- Companion pages for C++, Rust, Python, and JavaScript are accessible from links in the left panel.
- Navigation through example levels for the same language is effected with the "Next" and "Prev" buttons in the menus or by using the "N" and "P" keys.
- The links in the left panel point to major sections of this page and all of the Bits pages for C#.
Note:
Most page links in this site refer to specific points in a target page, usually the top. For all of the code bits here, links return to the last scroll position. This supports quickly moving between similar code for each of the languages covered. That maintains context for comparisons.
Most page links in this site refer to specific points in a target page, usually the top. For all of the code bits here, links return to the last scroll position. This supports quickly moving between similar code for each of the languages covered. That maintains context for comparisons.
Source Code
// See https://aka.ms/new-console-template for more information
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello C# World");
}
}
}
Output
C:\github\JimFawcett\Bits\CSharp\Cs_Hello
> dotnet run
Hello C# World
C:\github\JimFawcett\Bits\CSharp\Cs_Hello
Build
C:\github\JimFawcett\Bits\CSharp\Cs_Hello
> dotnet build
MSBuild version 17.4.1+fedecea9d for .NET
Determining projects to restore...
All projects are up-to-date for restore.
Cs_Hello -> C:\github\JimFawcett\Bits\CSharp\Cs_Hell
o\bin\Debug\net7.0\Cs_Hello.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.75
C:\github\JimFawcett\Bits\CSharp\Cs_Hello
>
Create Project
C:\github\JimFawcett\test
> dotnet new console -n CSharp_Hello
The template "Console App" was created successfully.
Processing post-creation actions...
Restoring C:\github\JimFawcett\test\CSharp_Hello\CSharp_Hello.csproj:
Determining projects to restore...
Restored C:\github\JimFawcett\test\CSharp_Hello\CSharp_Hello.csproj (in 50 ms).
Restore succeeded.
C:\github\JimFawcett\test
> cd CSharp_Hello
C:\github\JimFawcett\test\CSharp_Hello
> dir
Directory: C:\github\JimFawcett\test\CSharp_Hello
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2/24/2023 9:41 AM obj
-a---- 2/24/2023 9:41 AM 249 CSharp_Hello.csproj
-a---- 2/24/2023 9:41 AM 105 Program.cs
C:\github\JimFawcett\test\CSharp_Hello
>
2.0 VS Code View
3.0 References
Reference | Description |
---|---|
C# Tutorial - Microsoft | Video and Presentations of simple examples |
Interactive Tutorials - W3Schools | Short examples with remote execution |
Bits Tooling | Tool chains, VS Code |