Lucky hour! Grab a free trial license — offer ends in 00:59:58. Claim now
The analyzer has detected a meaningless comparison between the result of calling the GetType method on a Nullable<T> object and typeof(Nullable<T>). The GetType method always returns the underlying type for values of the Nullable<T> type.
The example:
public void Foo<T>(Nullable<T> value) where T : struct
{
if (value.GetType() == typeof(Nullable<int>))
{
....
}
....
}
In this case, the comparison result is always false, because calling value.GetType() returns the T type.
The fixed code:
public void Foo<T>(Nullable<T> value) where T : struct
{
if (value.GetType() == typeof(int))
{
....
}
....
}
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders: