The analyzer has detected a potential error when an instance of a class derived from 'System.Exception' is created but not being used in any way.
Here's an example of incorrect code:
public void DoSomething(int index)
{
if (index < 0)
new ArgumentOutOfRangeException();
else
....
}
In this fragment, the 'throw' statement is missing, so executing this code will only result in creating an instance of a class derived from 'System.Exception' without it being used in any way, and the exception won't be generated. The correct version of this code should look something like this:
public void DoSomething(int index)
{
if (index < 0)
throw new ArgumentOutOfRangeException();
else
....
}
This diagnostic is classified as:
|