protected static SqlParameter CreateParameter(string name, object value, bool skipEmpty, bool isOutput =false)
{
if (skipEmpty && value is string && string.IsNullOrEmpty((string)value))
return null;
//1
if (skipEmpty && value is int? && value == null)
return null;
//2
if (skipEmpty && value is Guid? && value == null)
return null;
//....................
}
resharper 说 1 和 2 子句总是错误的。但是为什么?
最佳答案
如果值为 null,则不可能从中推断出比 object
更复杂的类型,因此它永远不可能是 int?
或 Guid?
关于c# - .NET 中的可空类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5511670/