gpt4 book ai didi

c# - 将列表转换为参数 C#

转载 作者:太空狗 更新时间:2023-10-29 19:59:24 38 4
gpt4 key购买 nike

我有以下列表:

var myList = new List<KeyValuePair<string, object>>();

还有这个函数:

public void Test(params KeyValuePair<string, object>[] list)

如何在使用函数时将列表转换为参数?像那样:

Test(myList);

最佳答案

你的方法声明KeyValuePair<string, object>[] list声明它将接受一个数组,因此您需要像这样将列表转换为数组

Test(myList.ToArray());

关于c# - 将列表转换为参数 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42923480/

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