如何生成字符串对数组? 我需要它用静态数据快速初始化它。
stringPair[] arr = {{"hgh","hjhjh"},{"jkjk","kjhk"}
最佳答案
您可以使用列表/数组 Tuple类
例子
List<Tuple<string, string>> data = new List<Tuple<string, string>>{
new Tuple<string, string>("Hello", "World"),
new Tuple<string, string>("Foo", "Bar")
};
根据@Eric Lippert 的评论,使用 Tuple.Create
List<Tuple<string, string>> data = new List<Tuple<string, string>>{
Tuple.Create("Hello", "World"),
Tuple.Create("Foo", "Bar")
};
关于c# - 字符串对数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20973996/