-1

I am new to C# and this code does not compile. I am trying to populate the List. The syntax of the three record values contains squiggly lines. Can you please help me? Thanks...John

private class Divisions {
   protected int uidDvsn { get; set; }
   protected string nameDvsn { get; set; }
}
private List<Divisions> divisions = {{1, "AL"}, { 2, "KEN" }, { 3, "FLA" }}; 
Peter Duniho
  • 68,759
  • 7
  • 102
  • 136
John D
  • 517
  • 7
  • 22
  • C# does not have such class initializer ({1, "AL"}) only for dictionary key-value. {new Divisions{uidDvsn =1, nameDvsn = "AL"}} will be valid. – Dmitriy Korolev Apr 25 '21 at 00:44

1 Answers1

1

The best way to do it, by using the following instruction:

private List<Divisions> divisions = new List<Divisions>() {
     new Divisions() { uidDvsn = 1, nameDvsn = "AL" },
     new Divisions() { uidDvsn = 2, nameDvsn = "KEN" }
};