我想知道如果函数中的if条件不为真,在C#中我可以返回0.
char Foo(int a)
{
if(a>0)
return 'a';
else
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这显示错误,因为我不能像这样返回0.
当然我可以做点什么
const char NULL = 'b';
Run Code Online (Sandbox Code Playgroud)
但我希望有更好的解决方案.有任何想法吗?