Skip to main content

RCS1165: Unconstrained type parameter checked for null

Properties​

PropertyValue
Default SeverityHidden
Minimum language version-

Examples​

Example #1​

diagnostic.cs
public void Foo<T1>() where T1 : new()
{
var x = default(T1);

if (x == null)
{
}
}
fix.cs
if (EqualityComparer<T1>.Default.Equals(x, default(T1)))
{
}

Applies to​