Possible to initialize multiple variables from a tuple?

前端 未结 7 659
孤独总比滥情好
孤独总比滥情好 2021-01-17 10:17

In some languages (such as PHP, Haskell, or Scala), you can assign multiple variables from tuples in a way that resembles the following pseudocode:

list(stri         


        
7条回答
  •  忘掉有多难
    2021-01-17 10:56

    Yes it is possible in C#. You'll need to install the package Value.Tuple in your project. You can do like this

    List>() lstTuple = GetYourTupleValue();
    foreach(var item in lstTuple)
    {
      (string Value1, string Value2 ) = item;
    }
    Console.WriteLine(item.Value1);
    

提交回复
热议问题