gpt4 book ai didi

Delphi 中的 C# 等价物

转载 作者:可可西里 更新时间:2023-11-01 08:57:56 25 4
gpt4 key购买 nike

对于 Delphi 的语法,C# 中的等价物是什么,例如:


if (iIntVar in [2,96]) then
begin
//some code
end;

谢谢

最佳答案

我更喜欢这里定义的方法:Comparing a variable to multiple values

这是 Chad 帖子的转换:

public static bool In(this T obj, params T[] arr)
{
return arr.Contains(obj);
}

用法是

if (intVar.In(12, 42, 46, 74) ) 
{
//TODO: Something
}

if (42.In(x, y, z))
// do something

关于Delphi 中的 C# 等价物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2357096/

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