C#

init-only properties

Në shqip: Vetitë init

ShpjegimiSQ

Me { get; init; } një veti mund të vendoset vetëm kur krijohet objekti (me object initializer), pastaj s'ndryshon më. Me required, kompajleri të detyron ta vendosësh.

EnglishEN

With { get; init; } a property can only be set when the object is created (with an object initializer), and never changes afterwards. With required, the compiler forces you to set it.

Si ta mendosh

Si emri në certifikatën e lindjes: shkruhet një herë dhe mbetet.

Lexoje në anglisht

Like the name on a birth certificate: written once and it stays.

Shembull kodicsharp

public class Nxenes {
    public required string Emri { get; init; }
}
var n = new Nxenes { Emri = "Arta" };

Terma të lidhur