C# 9.0 - Optional "Main"

wrijugh

Wriju's Blog

Posted on November 12, 2020

C# 9.0 - Optional "Main"

To run a C# code now we don't need namespace, main etc. Just run it

using System;

Console.WriteLine("Hello one line C# 9.0");

//namespace CSharp9
//{
//    class Program
//    {
//        static void Main(string[] args)
//        {
//            Console.WriteLine("Hello one line C# 9.0"); 
//        }
//    }
//}
Enter fullscreen mode Exit fullscreen mode

Even this works

using System;

Console.WriteLine("Hello one line C# 9.0");
Console.WriteLine("Hello one line C# 9.0");
if (1 == 1)
{
    Console.WriteLine("if con");
}

Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
wrijugh
Wriju's Blog

Posted on November 12, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

C# 9.0 - Record Type
csharp9 C# 9.0 - Record Type

November 13, 2020

C# 9.0 - Optional "Main"
csharp9 C# 9.0 - Optional "Main"

November 12, 2020