Aller au contenu

« Csharp 11 » : différence entre les versions

De Banane Atomic
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 2 : Ligne 2 :
= Links =
= Links =
* [https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-11 What's new in C# 11]
* [https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-11 What's new in C# 11]
= [https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties#required-properties Required members] =
{{info | Don't confuse {{boxx|required}} with non-nullable.}}
<kode lang='cs'>
public class Item
{
    public Person() { }
    [SetsRequiredMembers]
    public Person(string firstName) => FirstName = firstName;
    public required string Name { get; init; }
}
</kode>


= [[String#Raw_string_literals|Raw string literals]] =
= [[String#Raw_string_literals|Raw string literals]] =

Version du 18 janvier 2025 à 14:04

Links

Required members

Don't confuse required with non-nullable.
public class Item
{
    public Person() { }

    [SetsRequiredMembers]
    public Person(string firstName) => FirstName = firstName;

    public required string Name { get; init; }
}

Raw string literals