📌  相关文章
📜  c# 检查 int 是否为空 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:12.884000             🧑  作者: Mango

代码示例1
// When trying to check if your int is null or i.e. 'not set',
// you will get the following error:

// The result of the expression is always 'false'
// since a value of type 'int' is never equal to 'null' of type 'int?'

// You can however bypass this by converting your int to string:
int myInt = null;
// This Method will return a bool;
bool isNullInt = string.IsNullOrEmpty(myInt.ToString());
// isNullInt will be in this case true