<分区>
这是 JavaScript 中非常常见的技术,但我想确保我可以在 C# 中做到这一点。
我在函数 DoSomething()
中,在执行调用期间,我需要用不同的值调用同一个函数。见下文:
public bool DoSomething(int id)
{
if(id < 100)
{
// Some logic here
var someValue = id + 50;
var outcome = DoSomething(someValue);
// Some more logic here
}
else
{
// Some other logic here
}
}
我看不出为什么我不能执行上述操作,但想看看这在 C# 中是否是一种不好的做法。