Answers for "how to initialize a list of tuples in c#"

C#
0

how to initialize a list of tuples in c#

var tupleList = new List<(int, string)>
  {
      (1, "cow"),
      (5, "chickens"),
      (1, "airplane")
  };
// or
  var tupleList = new(int, string)[]
  {
      (1, "cow"),
      (5, "chickens"),
      (1, "airplane")
  };
//or
  var tupleList = new List<(int Index, string Name)>
  {
      (1, "cow"),
      (5, "chickens"),
      (1, "airplane")
  };
// or
  var tupleList = new (int Index, string Name)[]
  {
      (1, "cow"),
      (5, "chickens"),
      (1, "airplane")
  };
Posted by: Guest on September-30-2020

Code answers related to "how to initialize a list of tuples in c#"

C# Answers by Framework

Browse Popular Code Answers by Language