Announcing .NET 6 Release Candidate 2

Richard Lander

We are excited to release .NET 6 Release Candidate 2. It is the second of two “go live” release candidate releases that are supported in production. For the last couple months, the team has been focused exclusively on quality improvements. There are a lot of new features in the release, which only fully come together near the end. The team is currently validating end-to-end workflows to find the places where design intentions and technical reality don’t yet fully match. That’s led to teams tightening leaky pipes and paving paths all the way to their destination.

We’ve heard from users that upgrading production sites to .NET 6 RC1 has been both “boring” (non-event) and “exciting” (significant performance improvements). We’re confident that RC2 will continue that trend of having no surprises and exciting results.

You can download .NET 6 Release Candidate 2 for Linux, macOS, and Windows.

See the .NET MAUI and ASP.NET Core posts for more detail on what’s new for client and web application scenarios.

.NET Conf is a free, three-day, virtual developer event that celebrates the major releases of .NET. This year, .NET 6 will launch at .NET Conf November 9-11. We encourage you to save the date and tune in. Visual Studio 2022 Preview 5 is also releasing today and they have also announced that launch event happening on November 8. You can read all about that on the Visual Studio blog.

We’re at that fun part of the cycle where we support the new release in production. We genuinely encourage it. You can reach out to us at if you need guidance on how to approach that. A bunch of businesses have reached out and some are now in production. We also help Microsoft teams run on RC releases. Some Microsoft teams have gone into production on RC1 and we expect many more on RC2. This includes the .NET Website.

.NET 6 RC2 has been tested and is supported with Visual Studio 2022 Preview 5, also releasing today. .NET 6 will be supported with Visual Studio 2022 and not Visual Studio 2019. Similarly, it will be supported with MSBuild 17.x and not 16.x. If you want to use .NET 6, you will need to upgrade to Visual Studio 2022.

Visual Studio 2022 for Mac is currently NOT compatible with .NET 6 RC2. We are in the process of resolving that.

Check out the new conversations posts for in-depth engineer-to-engineer discussions on the latest .NET features.

The .NET 6 RC1 post was focused on foundational features, many of which will not see their full fruition until .NET 7. This post is focused on C# 10 and the related improvements to templates. It also includes an update on macOS and Windows Arm64 (which includes breaking changes). Let’s take a look.

C# 10

C# 10 is an important part of the .NET 6 release. For the most part, C# 10 is a further evolution of existing concepts and capabilities, like records and patterns. It also includes features — global using and file-scoped namespaces — that help you simplify your code and write less boilerplate. Those specific improvements are the basis of the template changes that are discussed later in this post. You can see the examples used in this section at .NET 6 examples. I’ll add more examples there for the final .NET 6 post.

Record structs

C# 10 adds support for record structs. This new feature is similar to C# 9 (class-based) records, with some key differences. For the most part, record structs have been added for completeness so that structs can enjoy the same record benefits as classes. However, the team did not simply structify records, but decided to align struct records with ValueTuple as much as class records. As a result of that design approach, record struct properties are mutable by default, while record class properties are immutable. However, you can declare a readonly record struct, which is immutable and matches the record class semantics.

At a high level, record structs do not replace record classes, nor do we encourage migration of record classes to record structs. The guidance for using classes vs structs applies equally to record classes and record structs. Put another way, the choice between classes and structs should be made before choosing to use records.

Let’s take a look at how record structs differ from record classes

This example of a record struct produces the following output.

Battery { Model = CR2032, TotalCapacityAmpHours = 0.235, RemainingCapacityPercentage = 100 }
Battery { Model = CR2032, TotalCapacityAmpHours = 0.235, RemainingCapacityPercentage = 0 }

As already stated, the most obvious difference is that record struct properties are mutable by default. That’s the key difference beyond being structs and the record struct syntax. I’ve also re-written the example with a readonly record struct, as follows.

You’ll see that it is almost identical to the (class) record example I published for C# 9.

Let’s review C# 9 records. They provide a terse syntax for defining struct-like data-oriented classes. They bias to immutability while offering a terse syntax — with expressions — for immutable-friendly copying. It might have surprised folks that we started with classes for a feature that is intended to be struct-like. Most of the time, developers use classes over structs, due to pass by reference as opposed to value semantics. Classes are the best choice in most cases and easier to use.

Struct records are very similar to class records:

  • They use the same syntax (with the exception of struct or class in the definition).
  • They enable customizing member definitions (new in C# 10) to use fields over (by default) property members.
  • They enable customizing the member behavior, using init or mutable properties.
  • They support with expressions. In fact, starting in C# 10, all struct types support with expressions.

Struct records differ from class records:

    • Record structs are defined with record struct or readonly record struct.
    • Record classes are defined with record or record class.
    • Record struct properties are mutable (get/set) by default.
    • Record class properties are immutable (get/init) by default.

The asymmetric (im)mutability behavior between record structs and record classes will likely be met with surprise and even distaste with some readers. I’ll try to explain the thinking behind the design. By virtue of pass by value semantics, structs don’t benefit from immutability nearly as much as classes. For example, if a struct is a key in a dictionary, that (copy of the struct) key is immutable and lookups will be performed via equality. At the same time, the design team saw that ValueTuple can be thought of as an anonymous record struct and that record structs can be seen as a grow-up from ValueTuple. That only works if record structs embrace mutability and support fields, which is exactly what the team decided to do. Also, embracing mutability is a reflection that structs and classes are different.

If you prefer the immutable behavior with record structs, you can have it by adding the readonly keyword.

Looking at structs generally, key functionality is common:

  • Equality checks are the same for all structs, provided by the runtime.
  • All structs can use with expressions for creating non-mutating copies, which is new in C# 10.

Global usings

global using enables you to specify a namespace that you would like available in all of your source files, as if it was declared in each one. It can also be used with using static and aliasing. This feature enables a common set of using declarations to be available, and by extension, for many using lines to no longer be needed. This is most relevant for the platform namespaces, but can be used for any namespace.

The following syntax can be used for the various using forms:

  • global using System;
  • global using static System.Console;
  • global using E = System.Environment;

These declarations just need to be declared once in your compilation to be effective throughout it. There are four patterns for declaring global using.

  • In Program.cs, make your root using statements global to the whole program by upgrading them to global using.
  • In a GlobalUsings.cs file (or some similar name), centrally manage all of your global using statements.
  • In your project file, with syntax that follows.
  • In your project file, enable the default platform using statements (for the MSBuild SDK your app relies on), with syntax that follows.

The following MSBuild syntax can be used in place of .cs files, in an <ItemGroup> (using analogs of the earlier examples).

  • <Using Include="System"/>
  • <Using Include="System.Console" Static="True"/>
  • <Using Include="System.Environment" Alias="E"/>

You can enable implicit using statements defined by the platform in a <PropertyGroup>.

  • <ImplicitUsings>enable</ImplicitUsings>

Implicit using differs by MSBuild SDK. Microsoft.NET.Sdk defines a basic set, and other SDKs define additional ones.

If you use the MSBuild capabilities, you can see the effective result in a generated file in the obj directory, as demonstrated by the following.

PS C:\Users\rich\app> type .\app.csproj | findstr Using
    <Using Include="System.Console" Static="True"/>
    <Using Include="System.Environment" Alias="E"/>
PS C:\Users\rich\app> type .\obj\Debug\net6.0\app.GlobalUsings.g.cs
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
global using E = global::System.Environment;
global using static global::System.Console;

You can see that the Microsoft.NET.Sdk adds several global using statements, in the .GlobalUsings.g.cs file. Note that the global:: operator isn’t necessary and can be safely ignored in terms of developing an understanding of the generated syntax.

File-scoped namespace declaration

File-scoped namespace declarations is another C# 10 feature that is aimed at reducing indentation and line count.

The syntax for this feature follows:

namespace Foo;

It is an alternative to the traditional three-line syntax:

namespace Foo

The three-line syntax can be nested. The one-line syntax does not support nesting. There can only be one file-scoped declaration per file. It must precede all types defined in the file, much like the three-line syntax.

Namespaces are not compatible with top-level statements. Top-level statements exist within the top-level namespace. This also means that if you add additional methods to the Program class, using the partial class syntax that the partial Program class needs to also be in the top-level namespace.

This feature is very similar to the one-line using declaration that was added to C# 8.

const and interpolated strings

Interpolated strings can now be assigned to const variables. Interpolated strings are intuitive to use and read, and should be usable everywhere. They can now be used with const provided that the placeholder values are also constant.

The following example demonstrates a possible use case:

Many other improvements have been made to interpolated strings, which are described in String Interpolation in C# 10 and .NET 6.

Extended property patterns

You can now reference nested properties or fields within a property pattern. For example, the following pattern is now legal:

{ Prop1.Prop2: pattern }

Previously, you’d need to use a more verbose form:

{ Prop1: { Prop2: pattern } }

You can see this more compact form used in the following example, for example with Reading.PM25.

.NET SDK: C# project templates modernized

We modernized .NET SDK templates with Preview 7, using the latest C# features and patterns. There was significant feedback on those changes, in part because builds started to fail. As part of the initial templates update, we enabled implicit usings by default (AKA opt-out) for .NET 6 (net6.0) projects (including if you updated an app from .NET 5 to .NET 6). That has been changed. We’ve updated the SDK so that all the new features are opt-in. The response to that change (which was made in RC1) has been positive.

There was also feedback that some folks didn’t like the new simplified Program.cs file, with top level statements. We’ve made improvements to top-level statements in response and continued to use it for templates. We expect that most developers who prefer the traditional approach can straightforwardly add the extra ceremony themselves.

The following language features are used in the new templates:

  • async Main
  • Top-level statements
  • Target-typed new expressions
  • Global using directives
  • File-scoped namespaces
  • Nullable reference types

We built all of these features because we think that they are better than the previous alternative. Templates are the easiest and best way to steer new developers and new apps to use the best patterns. The C# design team is a big believer in enabling the use of fewer lines, fewer characters to specify a given concept or operation, and the reducing needless repetition. That’s what most of these new features enable. Nullable differs in that it results in more reliable code. Every app or library that uses nullable is less likely to crash in production. Software is too complicated for human minds to see the mistakes that a compiler can.

A common theme across these features is that they reduce noise and increase signal when you are looking at your code in a code editor. More important aspects should now pop. For example, if you see a using statement in a given file, it’s a special one needed beyond the implicit set. You should be able to copy/paste code from one file to another without needing to CTRL-. types to add the required namespaces (at least not as much). If you see nullable warnings or errors, you know that your code is likely incorrect in some way. There is also the benefit of removing indentation. More of your code will be visible within the first dozen columns of your editor, as opposed to those columns being filled with just space characters. One can think of these features as delivering higher density of specificity and meaning to your eyes, on the way to your brain.

Console template

Let’s start with the console template. It’s very small.


// See for more information
Console.WriteLine("Hello, World!");

Project file:

<Project Sdk="Microsoft.NET.Sdk">



Even though the console template is much more minimal that its .NET 5 counterpart, there is no reduction in functionality. You can also see that ImplicitUsings is now an opt-in feature, and is enabled in the templates.

Web templates

The web template is similarly minimal.

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () => "Hello World!");


The webapi template maps more closely to typical ASP.NET Core apps. You will quickly notice that the split between Program.cs and Startup.cs has been removed. Startup.cs is no longer required.


var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

// Learn more about configuring Swagger/OpenAPI at

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())





The project file for the webapi template is similar to the console one.

<Project Sdk="Microsoft.NET.Sdk.Web">


    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.5" />


You can see that file-scope namespaces are used throughput this sample, including in WeatherForecast.cs:

namespace webapi;

public class WeatherForecast
    public DateTime Date { get; set; }
    public int TemperatureC { get; set; }
    public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
    public string? Summary { get; set; }

Target-type new is used with WeatherForecastController.cs:

private static readonly string[] Summaries = new[]
    "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"

In the mvc template, you can see the use of nullable annotations and an expression-bodied method.

namespace webmvc.Models;

public class ErrorViewModel
    public string? RequestId { get; set; }

    public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

Windows Forms templates

The Windows Forms template has also been updated. It includes most of the other improvements covered with the other templates, although notably not top-level statements.

namespace winforms;

static class Program
    /// <summary>
    ///  The main entry point for the application.
    /// </summary>
    static void Main()
        Application.Run(new Form1());

You can see the use of the one-line namespace statement and the lack of any platform-level using statements due to enabling implicit usings.

WPF templates have not been updated as part of the release.

Implicit usings

I’ll now show you these features in action. Let’s start with implicit usings. When enabled, each Sdk adds its own set of implicit using statements.

As demonstrated earlier, the Microsoft.NET.Sdk adds several global using statements.

If this feature is disabled, you’ll see that the app no longer compiles since the System namespace (in this example) is no longer declared.

PS C:Usersrichapp> type .app.csproj | findstr Implicit
PS C:Usersrichapp> dotnet build
Microsoft (R) Build Engine version 17.0.0-preview-21501-01+bbcce1dff for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  You are using a preview version of .NET. See:
C:UsersrichappProgram.cs(2,1): error CS0103: The name 'Console' does not exist in the current context [C:Usersrichappapp.csproj]


Another option is to use the global using feature, which enables you to only use the namespaces you want, as you can see in the following example.

<Project Sdk="Microsoft.NET.Sdk">


    <Using Include="System" />


Now, building the code.

PS C:Usersrichapp> type .app.csproj | findstr Using
  <Using Include="System" />
PS C:Usersrichapp> dotnet build
Microsoft (R) Build Engine version 17.0.0-preview-21501-01+bbcce1dff for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  You are using a preview version of .NET. See:
  app -> C:UsersrichappbinDebugnet6.0app.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.80

That’s not the recommended general pattern, but is a good option for folks that want maximum control. In most cases, we expect that developers will rely on the implicit usings provided by the SDK and take advantage of explicit global usings for namespaces from their own code or NuGet packages that they use pervasively.


I’ve updated Program.cs to demonstrate nullable reference types. The app calls a List<T> method that returns a T?, in this case a nullable string (string?).

List<string> greetings = new()
    "Nice day, eh?"

string? hello = greetings.Find(x => x.EndsWith("!"));
string greeting = hello ?? "Hello world!";

Console.WriteLine($"There are {greeting.Length} characters in "{greeting}"");

The line that defines the hello variable won’t compile without being defined as var, string? or addressing the case where List<T>.Find returns null. Without the nullable feature enabled, I might miss this problem, which would result in my code crashing with a NullReferenceException exception. That’s no good. I’m handling that on the next line with ??, the null coalescing operator. In most cases, these two lines would be merged into one, as you can see in the following code. I’ve kept them separate (in this contrived example) so that you can see my use of string? to accommodate an API that returns a nullable reference type.

string greeting = greetings.Find(x => x.EndsWith("!")) ?? "Hello world!";

In this example, I’ve merged everything into one line. I can now declare the variable as string since the null-ness has been accommodated with the string that follows ??. The string? in this case is something that only the compiler sees.

string[] args

I’m now going to quickly address the questions that most people ask about top-level statements, including the args parameter. The args parameter remains available with top-level statements. It’s just less obvious. Here’s another program that demonstrates using it.

string greeting = args.Length > 0 ? string.Join(" ", args) : "Hello World!";
WriteLine($"There are {greeting.Length} characters in "{greeting}" in this {nameof(Program)}.");

It produces the following output.

PS C:\Users\rich\app> dotnet run
There are 12 characters in "Hello World!" in this Program.
PS C:\Users\rich\app> dotnet run Nice day, eh?
There are 13 characters in "Nice day, eh?" in this Program.

This app also demonstrates that the Program type is still defined. Program.Main is not.

I removed the Console from Console.WriteLine in Program.cs by adding a global static using to my project file, as follows.

<Project Sdk="Microsoft.NET.Sdk">


    <Using Include="System.Console" Static="True"/>


Defining regular methods

We’ve heard the feedback from some folks that real methods are preferred over local functions, specifically for the Program class. You can use either model with top-level statements.

I’ve kept the program the same, but switched all the functionality to static method in the Program class, defined in a partial class.




public partial class Program
    public static string GetTheGreeting(string[] args)
        string greeting = args.Length > 0 ? string.Join(" ", args) : "Hello World!";
        return $"There are {greeting.Length} characters in "{greeting}" in this {nameof(Program)}.";

It produces the same result as the previous example. The Program.Foo.cs filename is arbitrary. In fact, so is Program.cs. You can name these files whatever you’d like. The compiler will figure it out.

As mentioned earlier, the Program type must be in the top-level namespace when using top-level statements.

macOS and Windows Arm64 Update

We have good news, but also some breaking change to share. The project to support macOS and Windows arm64 is almost done. We’ve been working on it for over a year, with help when we needed it from the fine folks on the macOS and Windows teams. At first, we thought that the project was solely about supporting Arm64 on macOS and that Rosetta 2 would cover x64. Easy and just about ISAs, right? Not quite. As we dug deeper, it became clear that x64 + Arm64 co-existence was the bigger task to take on, focused on the CLI and installers, including a few places where they need to agree. With RC2, we’re delivering builds of .NET that we deliver the best experience we could imagine.

I’ll provide a quick summary of where we are at for macOS and Windows Arm64 machines:

  • .NET 6 RC2 enables Arm64 + x64 co-existence by installing Arm64 and x64 builds to different locations. Until now, Arm64 and x64 builds overwrite each other, which led to general sadness.
  • You need to uninstall all .NET builds and start from scratch (on macOS and Windows Arm64 machines) to adopt .NET 6 RC2+. This includes Arm64 and x64, .NET 6 and pre-.NET 6.
  • Pre .NET 6 builds are not yet ready to install.
  • The CLI enables you to use the Arm64 SDK to do Arm64 AND x64 development (assuming you have the required Arm64 and x64 runtimes installed). The same is true in reverse.
  • We want people to just use the Arm64 SDK since it will be a better experience (native architecture performance; one SDK to maintain). We will continue to improve the product to make this model the easy choice for most developers.
  • For the SDK, we will only support .NET 6+ on Arm64. Earlier SDK builds will be blocked on Arm64.
  • For runtimes, we will support all in-support versions, Arm64 and x64.
  • .NET 6 RC2 delivers the bulk of the final .NET 6 experience for Arm64 (including x64 emulation).
  • We hope to update .NET Core 3.1 and .NET 5 runtimes to align with .NET 6 RTM (both in time and with the technical requirements). That’s still TBD.
  • RC2 nightly builds are currently broken, so you will need to wait a couple more weeks until we actually ship RC2 to try this all out.
  • The .NET 5 SDK for Windows Arm64 will go out of support early, with .NET 6 RTM.

We’re also considering making breaking changes to dotnet test to unify the arguments we use for architecture targeting:

A big part of the project is enabling the use of x64 runtimes with the Arm64 SDK. You can see that demonstrated in the following image.

x64 on Arm64, Announcing .NET 6 Release Candidate 2

If you want more details, check out dotnet/sdk #21686.

Contributor showcase

In developing .NET 6, we appreciate the many contributions of our GitHub community. As we did in our Preview 7 and RC1 posts, we’d like to recognize just a few of those.

This text is written in the contributors’ own words:

Alexandr Golikov (@kirsan31)

My name is Alexandr Golikov and I am from Saint Petersburg, Russia.

I have been writing stock trading software for over 15 years, mostly with .Net Framework and WinForms. As soon as .Net Core WinForms became open source and a preview version was released, I started trying to migrate our projects into it and contribute to solving both old problems that were in .Net Framework and new ones. At this moment all of our projects are working on .Net 5.0. But .Net 6 is already almost here, and .Net 7 is on the horizon, and… I hope that I will continue to contribute to this great framework, and will have more free time for this 🙂

In the end, I want to thank the whole .Net team and especially the WinForms project developers and maintainers!

Tobias Käs (@weltkante)

I’m Tobias Käs and mostly visible under the alias weltkante on github. I’m from Germany, studied computer science in Frankfurt and am currently living in Mönchengladbach. I’m coming from a low level C++ programming background but have switched to C# programming as my main language ever since it distinguished itself from Java by adding generics in .NET 2.0.

I’ve been working over 12 years programming desktop applications in .NET Framework using WinForms and later WPF. I have spent a lot of time digging into the internals of .NET and its UI frameworks to learn how they work, debugging issues, finding workarounds, and in general getting the most out of these frameworks. Ever since they went open source I’m trying to give back from what I learned, following issue discussions, commenting pull requests, or doing the occasional contribution.

Ivan Zlatanov (@zlatanov)

My name is Ivan Zlatanov, and I am from Botevgrad, Bulgaria. I dipped my toes in the world of software first in high school where we did competitive programming in Turbo Pascal. I’ve spent the next summer doing some PHP and learning about the web dev. Not long after an opportunity arose where I could learn C# and ASP.NET 2.0 and once I picked that, I never stopped. I’ve been programming with C# and .NET for almost 14 years now.

I love contributing to open-source projects because I can help others. I love the immediate feedback you get from reviews and the open discussion of problems and solutions with other people around the globe. As Scott Hanselman once said that we only have limited keystrokes left in each of us, so we better spend them well.

Contributing to Open Source and in particular .NET is keystrokes spent well.


C# 10 offers significant improvements in simplicity and expressiveness, building on similar features in C# 9. In the past, one could reasonably poke fun at C# for requiring so much ceremony and knowledge of object oriented concepts just to write a single line of code. Those days are behind us, and the templates reflect that. Part of the motivation for these changes has been to make C# more attractive to new programmers and schools. These simplifying changes fundamentally change what you need to learn to get started with and become skilled using C#. In its new default form, it is directly comparable to other languages that similarly start with a single file source file.

We look forward to seeing other projects simplify their new user experiences with top-level statements, global using, records and many of the other modern features. There is a lot of opportunity to create simpler learning journeys for both open source projects and commercial offerings.

We encourage you to use .NET 6 RC2. We’re confident that you’ll find it a solid release. And save the date for .NET Conf on November 9 for the .NET 6 launch.

Thanks for being a .NET developer.


Comments are closed. Login to edit/delete your existing comments

  • Mohan Murali 0

    Really excited for the new changes. This makes c# look so modern. Love the changes.

  • Alexander Batishchev 0

    So far the main defence line for the disliked features is “other languages do it too” and “we personally like it”. Neither holds the water.
    You like it, I don’t. I’m the user, how come my taste means less than yours? You’ve got it wrong, it’s the other way around.
    Please address the comments in substance. Have surveys, user studies, publish the results. Spend time and money. Defend your decision with data points. You’re the face and the voice of Microsoft after all.
    Until then – it’s just your taste over someone else’s. And a loss-loss for the community.

    • Richard LanderMicrosoft employee 0

      We did extensive user studies. That said, it was primarily focused on new users to C# and new programmers (with no programming background). Those studies demonstrated that fewer required concepts and lines of code improved satisfaction and effectiveness. These results are not surprising. I do not believe those studies focused on existing C# users.

      Let’s be clear. The comments on this post demonstrate that there is a polarized split among existing .NET developers. The people who don’t like it are trying to suggest the changes are uniformly bad and that no one likes them. That is objectively not true. It also diminishes the weight at least I want to place on that feedback.

      We are discussing adding a fixer to Visual Studio, along the lines of the experience of switching LINQ statements back and forth (declarative to imperative styles). My guess is that most of the people who dislike the new style are Visual Studio users as opposed to command line Linux users. Fair? Would that help?

      Also … it is trivial to convert a top-level statements project to the static void main style. Are people creating projects so often that this change is such an imposition? If you are creating projects so often, are they real apps or just some sort of sample/POC?

      • Emmanuel Hansen 0

        It is much more trivial converting a static main project to a top-level statement project. It’s simply, CTRL+A, DEL. 3 keys. Converting from a top-level project to a static main project needs more work. You have to go to a previous project or a text file with the template, copy it, paste it in your new Program.cs file, and fix your namespaces. More steps. I have no issue with top-level namespaces. My issue is making it the default for templates, and having no easy way to switch between them. Also, new users are still going to learn namespace and class structure when they start to make projects with more than 1 class. Which most will be doing when they are like 1 day into learning C#.

        • Richard LanderMicrosoft employee 0

          I understand your point. Templates are our opportunity to provide an opinionated statement on the best way to write apps. That’s exactly what folks are seeing. It’s opinionated and not everyone will agree.

          Most professional developers spend 99% of their time working on an existing applications, making this topic irrelevant most of the time. We’re not changing any existing features. It was wrong to make implicit using a default behavior and we changed that.

          • Kathleen DollardMicrosoft employee 0

            To clarify… Implicit Global Usings is the default for new templates, via an entry in the generated .csproj file. It is an opt-in model, and the template opts you in.

            In one of the previews, it was an opt-out model. For your existing projects, if you did not opt-out you had new global usings in existing projects. That part was the mistake that Richard was referring to, and we reversed it.

            We believe that Implicit Global Usings is a great feature for new code, but it had a back-compat issue with existing projects.

      • Kirsan 0

        We did extensive user studies. That said, it was primarily focused on new users to C# and new programmers (with no programming background). Those studies demonstrated that fewer required concepts and lines of code improved satisfaction and effectiveness.
        This is obviously. But does they understand what is going on under this fewer lines of code? – NO!

      • Andy Patrick 0

        “The people who don’t like it are trying to suggest the changes are uniformly bad and that no one likes them. That is objectively not true.” – another thing that is objectively not true, is the claim that everyone who doesn’t like it is saying that. That’s just not true at all.

        “it is trivial to convert a top-level statements project to the static void main style.” – far more trivial to go the other way around. And the WHOLE POINT of a template is to fill in the trivial but boring stuff so that human programmers don’t have to.

      • Gopi Rajaseharan 0

        A “Beginner” or “Coming from Linux” project template could make top-level statements the default. Any other template could use the traditional full syntax. I, for one, don’t create new projects every day or even every month. I suppose I could always create a project template for myself that exactly suits my needs in what my new project should have starting out.. VS has long provided this ability. I think the main concern for programmers here is the annoyance stemming from what they see as an increased amount of over-engineering in recent years.. and it looks like top-level statements have hit that sore spot.. again.

  • Shaun Tonstad 0

    Richard, the C# language is a love letter to object-oriented design. I doubt it was ever on Anders Hejlsberg’s roadmap to remove a requirement that developers specify a class! 🙂

    • Richard LanderMicrosoft employee 0

      static void main is not an object oriented concept. The Program class is almost never used in an OO manner.

  • anonymous 0

    This comment has been deleted.

    • Andy Patrick 0

      Great point.

  • hitesh davey 0

    I think Microsoft should buy out LINQPAD if they really want to make beginners’ learning curve easy.
    LinqPad is a one-stop tool for top-level statements, magic args, implicit Program class, and the Main method.

    It really helped me to learn a lot about DonNet, C#/ without using VS. It is a must-have tool for ALL DotNet developers.

  • Andy Patrick 0

    Let me add my voice to the crowd that object to top-level statements being used in project templates.

    What on earth is the point in a project template where the first thing I have to do every time I use it, is go and add in myself all the things that project templates are supposed to do for me?

    Why is the ability for a completely new programmer to take C# 101 and understand what Console.WriteLine(“Hello, world”); is doing, rated a higher priority than productivity and functionality for all developers every time they start a new project – even that self-same new programmer when they reach lesson two? It makes no sense.

    I’m all in favour of reducing cruft: file-scope namespaces are fine for example, I’ll even try out implicit usings. But why optimise for a unique corner case of “your first C# lesson”, which you’ll do once in your entire career, when it harms the normal case of “code you write every day”? Are we really to believe what is implied here – that MS devs’ egos are so fragile, that avoiding being teased about a non-issue as utterly inane as not being able to write a valid C# program with a single line in one file, is any kind of priority for them?

    If you really think making C# 101 easy should be a priority, create a separate template called “Hello World – C# for beginners” and do whatever you want with it. If there’s one called “New console project”, I expect to find a fully-formed, usable console project that I don’t have to add all the scaffolding to myself.

    (And if you’re wondering why I’m getting so wound up about this – in the early days of C#, every new version brought more joy, as useful new features were released that made developer’s lives easier. Recently, new versions of C#/.NET/whatever are about 60/40 joyful/irritating. You guys seem to have stopped focusing on making developer’s lives easier, and diluted your attention chasing other stuff, be it beginners, people who don’t like C# anyway, or whatever else. I just want you to put the focus back on what made C# so awesome in the first place. Play to your strengths!)

    • anonymous 0

      This comment has been deleted.

  • Alaa Masoud 0

    Great C# enhancements, love it!

  • Ian Marteens 0

    C# evolution has stopped to make any sense long time ago. Most of the pattern matching things are misguided. That’s what really confuse a novice, instead of the top-level stuff. But, of course, Computer Science has not being a thing for a long time. That was the discipline practiced and enforced by Knuth, Dijkstra, Hoare, Ullman and their crew. What we have now is something derived from the musings of Martin Fowler and his ilk. Where’s the wisdom we have lost in knowledge? Where’s the knowledge we have lost in information? Not in C# 10, for sure.

  • Mike-E 0

    I am late to the party here but have been wanting to share my absolute appreciation for the quality of this build + VS2022 Preview 5. Everything is BLAZING now… The build issue that I was experiencing where it was taking over 2 minutes for each build is now gone, and it’s actually faster than it was w/ .NET6 Preview 7. Builds are SOOOOOO much faster now and everything seems to be working great! I have been blissfully developing over the past few days and have been meaning to comment on how awesome it is now, so here it is. 🙂 Thank you so much for your talented and devoted efforts over there!

  • Luis Martins 0

    It seems that the general consensus around the top level statements is they add no value and if anything they just make things more confusing for new and old developers alike. Even the people I’ve seen that like the feature which are few and far between, seem to use as their argument that this is optional, if you don’t want it don’t do it. Yet Microsoft decided it was a good idea, to default the new templates to this new Syntax even after getting a huge backlash… You won’t be making any need new friends with this one that’s for sure.

    With that said I do wonder who exactly do you think you’re helping? New devs will still need to work in legacy applications… Meaning they’ll have to learn the different syntaxes anyway…. On top of that, not sure if everyone at Microsoft lives in a shielded bubble where everyone is the perfect developer, but out here in the real world maintaining code quality and standards across multi disciplinary teams with different levels of experience and knowledge it’s already hard and time consuming as it is. This won’t make it any easier.

    But all of this is still acceptable if it wasn’t for the fact that no real enterprise application has any use for some of these features as their utility is essentially limited to hello worlds and pocs.

    I’m going to take a wild guess here, a lot of people put a lot of hours and effort into these new features hoping this would be a widely accepted set of changes and after all the backlash didn’t want to admit they’ve made the wrong mistake and accept they wasted their time, cause time costs money and no one wants to take the hit for wasting the bosses money.

Feedback usabilla icon