溫馨提示×

c#元組創(chuàng)建的方法是什么

c#
小億
91
2024-03-18 19:03:33
欄目: 編程語言

在C#中,可以使用以下方法創(chuàng)建元組:

  1. 使用Tuple類:
Tuple<int, string> tuple = new Tuple<int, string>(1, "hello");
  1. 使用ValueTuple結(jié)構(gòu):
ValueTuple<int, string> valueTuple = (1, "hello");
  1. 使用強類型方法創(chuàng)建元組:
var tuple = (count: 1, message: "hello");

0