如何在 C# 中将元组转换为数组?
首先,设置元组 -
Tuple<int, int> t = Tuple.Create(99,53);
现在,将元组转换为数组 -
int[] arr = new int[]{t.Item1, t.Item2};以下是将元组转换为数组的代码 -
示例
using System;
using System.Linq;
using System.Collections.Generic;
namespace Demo {
public class Program {
public static void Main(string[] args) {
Tuple<int, int> t = Tuple.Create(99,53);
int[] arr = new int[]{t.Item1, t.Item2};
foreach (int val in arr) {
Console.WriteLine(val);
}
}
}
}输出
99 53
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP