gpt4 book ai didi

c# - 在字典中命名元组?

转载 作者:行者123 更新时间:2023-11-30 19:14:53 25 4
gpt4 key购买 nike

我正在尝试创建一个包含字符串键和元组值(字符串、 bool 值)的字典。我想让元组成为一个命名的元组,比如:

Dictionary<string, (string, bool)> spColumnMapping = new Dictionary<string, 
(string, bool)>();

这可能吗?

谢谢

最佳答案

void Main()
{
Dictionary<string, (string Foo, bool Bar)> spColumnMapping = new Dictionary<string, (string, bool)>();

spColumnMapping.Add("foo", ("Quax", false));

var x = spColumnMapping["foo"];

Console.WriteLine(x.Foo); // prints Quax
Console.WriteLine(x.Bar); // prints False
}

只需根据类型命名参数。

关于c# - 在字典中命名元组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51675115/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com