DEV Community

Wriju's Blog
Wriju's Blog

Posted on

4 1

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

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more