我的代码看起来像
private bool IsUserAditya(string username)
{
return username == "Aditya"? true : false;
}
我可以进一步缩短吗?
我将不胜感激。
最佳答案
Can I shorten it further?
有一点
返回用户名 == "Aditya";
C# 中的任何比较都会返回一个 bool
,因此无需使用条件运算符。
关于c# - 我该如何缩短 If else,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31918410/