gpt4 book ai didi

c# - Return value, Ref, Out 有什么区别吗?

转载 作者:太空宇宙 更新时间:2023-11-03 18:27:17 24 4
gpt4 key购买 nike

<分区>

我正在做这个,

public Order Add(Order order)
{
order.thisA = GetValue1();
// update the state of object
return order;
}

如果我在这里使用 Ref 或 Out 会有什么好处吗?

进一步的实现需要我添加这个方法,

public Order[] UpdateCollection(Order[] orderCollection)
{
foreach(Order o in orderCollection)
o = Update(o);

return orderCollection;
}

也请根据最佳实践告诉我。

上下文:

目前我只返回订单的 INT id,但将来我可能需要返回更多属性,但这里是完整的上下文,

https://codereview.stackexchange.com/questions/97778/crud-operation-class#

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