Skip to content

Instantly share code, notes, and snippets.

@crgrieve
Created December 23, 2020 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crgrieve/3df50a35ebf3b140ea5ffd0d4c6a35d3 to your computer and use it in GitHub Desktop.
Save crgrieve/3df50a35ebf3b140ea5ffd0d4c6a35d3 to your computer and use it in GitHub Desktop.
C# 9 init properties, error example.
using System;
var glasgowMeetup = new Meetup() {
City ="Glasgow",
Topic = ".Net"
};
glasgowMeetup.Topic = "Umbraco";
glasgowMeetup.City = "Edinburgh";
Console.WriteLine(glasgowMeetup);
public record Meetup
{
public string City { get; init; }
public string Topic { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment