I was writing some C# code using both the heavyweight Visual Studio integrated development environment program and the slightly lighter-weight Visual Studio Code IDE program. The experience reminded me that, in my opinion, the “top-level statements” feature is probably the worst idea I’ve seen in a software development environment in, well, maybe, my entire career in coding.
Let me explain.
Until about 2022, when you would create a new C# console application program using VS or VSC, you’d get a template like so (with some variations, depending on version of VS or VSC):
namespace MyNewProgram;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
This makes complete sense, is clear, and is easy to modify. Then, without warning, in 2020 with the release of C# version 9, some genius on the Visual Studio open source team decided that the default console application template would now use “top-level statements” and give you:
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
There’s no required parent Program class (it’s hidden so you’ll have to manually add it later), no required Main() method entry point (it’s there but invisible so you’ll have to manually add it later), no useful namespace structure (so you’ll probably have to manually add it later). How is this shortcut template better? Answer: It isn’t better, it’s worse. I’m utterly baffled how anyone who has ever worked in software development could think this new template is anything other than a terrible idea.
Let’s start with the name of the shortcut that eliminates required scaffolding statements — “top-level statements”. In other words, if you use “top-level statements” you do not get top-level statements in the template. What? Is this contradictory naming scheme some kind of a bad joke?
For several months in 2020, there was no easy way to get the good, old style template (you could create a custom template but that’s a minor pain). Mercifully, eventually, Visual Studio and VSC included an option to “Do not use top-level statements” during program creation wizard, which has the opposite effect for anyone who didn’t know the feature would assume.

Eventually, Visual Studio included an option to disable the horrible top-level statements feature for a new project.
For C# console applications intended for use in Visual Studio Code, you’d normally create a template from the command line “dotnet new console”, which give the same horrible shortcut template. Eventually an option was added so you could issue the command “dotnet new console –use-program-main”.
The moral of the story goes something like this. Inexperienced software developers who are working on a mature system are often desperate to prove their worth by adding a new feature. But sometimes new features, such as “top-level statements” aren’t useful. Put another way, sometimes something that looks bad at first glance is . . . just plain bad.
OK, I’m done ranting. But the next time I go on a rampage, I’ll talk about C# partial classes. Ugh! Another terrible idea (in my opinion).

Some of my favorite comedy movies feature absolute idiots who triumph in the end due to sheer luck.
Left: In “Dumb and Dumber” (1994), hapless Lloyd Christmas (actor Jim Carrey) and Harry Dunne (actor Jeff Daniels) have all kinds of adventures as they travel from Providence, Rhode Island (the city where my father was born in 1920) to Aspen, Colorado.
Center: In “Wayne’s World” (1992), semi-losers Wayne Campbell (actor Mike Meyers) and Garth Algar (actor Dana Carvey) create a public-access TV show that goes viral. On the right is actress Tia Carrera. I taught a summer school computer science class at her high school in Honolulu, HI when she was a senior. Althea (her real name) was already semi-famous at age 17. A few months ago, Carrera visited the Pacific Northwest and graciously met with several of her high school classmates, including my wife. Carrera is a genuinely nice person.
Right: In “Dude, Where’s My Car?” (2000), idiots Jesse (Ashton Kutcher) and Chester (Seann William Scott) wake up one morning with no memory of the night before, and they can’t find Jesse’s car. While looking for it, they meet a stripper, a angry Chinese woman, UFO cultists, non-shy high school classmate Christie, an ostrich farmer, two different groups of aliens, and discover they both have a tattoo on their back. A few years ago, I received a tattoo (an Irish four-leaf clover to honor my father) that I have no memory of getting, courtesy of one of my daughters — but that’s a long (and funny) story.
.NET Test Automation Recipes
Software Testing
SciPy Programming Succinctly
Keras Succinctly
R Programming
2026 Visual Studio Live
2025 Summer MLADS Conference
2026 DevIntersection Conference
2025 Machine Learning Week
2025 Ai4 Conference
2026 G2E Conference
2026 iSC West Conference
You must be logged in to post a comment.