Answers for "C# list initialize"

C#
2

c# how to set string list

// This will create a new list called 'nameOfList':
var nameOfList = new List<string> 
{
  "value1",
  "value2",
  "value3"
};
Posted by: Guest on October-28-2020
2

c# initialize list of objects

List<Cat> moreCats = new List<Cat>
{
    new Cat{ Name = "Furrytail", Age=5 },
    new Cat{ Name = "Peaches", Age=4 },
    null
};
Posted by: Guest on August-21-2020

C# Answers by Framework

Browse Popular Code Answers by Language