gpt4 book ai didi

c# - 一个参数或多个

转载 作者:太空狗 更新时间:2023-10-29 20:52:05 24 4
gpt4 key购买 nike

我有两种方法:

BuildThing(Thing a);
BuildThings(IEnumerable<Thing> things);

从代码简洁的角度来看,这样好吗?或者只使用 BuildThings 并仅通过一个 Thing 传递 IEnumerable 可能会更好?还是使用参数?

谢谢。

最佳答案

您可以做一件事:

BuildThings(params Thing[] things);

它使您能够使用:

BuildThings(thing1, thing2, thing3, ...);

关于c# - 一个参数或多个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5645683/

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