C# 11 — What You Need to Know

Michael Moreno
Nerd For Tech
Published in
6 min readNov 14, 2022

--

With .NET 7 and C# 11 out last week, I thought this would be a good excuse for me to put my fingers to the keyboard and write up a summary on some of the latest C# features, as much for my edification as your own.

Required Members

This feature is straightforward, but I feel like it requires (ha ha) a little history to fully appreciate, and so I present:

The Road to Required

About twenty years ago, if you had a class and you had to create an instance of it, it would look something like this:

static void Main()
{
Pet pet = new Pet("Fido", 3, 4);
}

class Pet
{
private string name;
private int age;
private int legs;

public string Name
{
get
{
return name;
}

set
{
name = value;
}
}

public int Age
{
get
{
return age;
}

set
{
age = value;
}
}

public int Legs
{
get
{
return legs;
}

set
{
legs = value;
}
}

public Pet(string name, int age, int legs)
{
this.name = name;
this.age = age;
this.legs = legs;
}
}

This is old-school, early 2000s C#. Aside from those properties, it’s not much better than Java. Notice how you are passing in the values for your Pet object through the constructor. The constructor ensures…

--

--