gpt4 book ai didi

.net - 将 Dictionary 转换为数组

转载 作者:行者123 更新时间:2023-12-01 08:39:01 24 4
gpt4 key购买 nike

我想在 C# 中将 Dictionary 转换为数组。该数组应采用以下格式:

string[] array = {"key1=value1","key2=value2","key1=value1"}

如何有效地做到这一点?

最佳答案

string[] array = dictionary
.Select(kvp => string.Format("{0}={1}", kvp.Key, kvp.Value))
.ToArray();

关于.net - 将 Dictionary<string,string> 转换为数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6275267/

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