This rule flags an unnecessary suppression or null-forgiving operator. The operator is unnecessary when it's used in a context where it has no effect. Use of the suppression operator, for example, x!, declares that the expression x of a reference type isn't null. However, when used in a context of another operator, for example, the is operator in o !is string, it has no effect and can be removed.
Options
This rule has no associated code-style options.
Example
C#
// Code with violationsif (o !isstring) { }
// Potential fixes:// 1.if (o isnotstring) { }
// 2.if (!(o isstring)) { }
// 3.if (o isstring) { }
Suppress a warning
If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.
C#
#pragmawarning disable IDE0080// The code that's violating the rule is on this line.#pragmawarning restore IDE0080
To disable the rule for a file, folder, or project, set its severity to none in the configuration file.
Izvor za ovaj sadržaj možete pronaći na GitHubu, gdje možete stvarati i pregledavati probleme i zahtjeve za povlačenjem. Dodatne informacije potražite u našem vodiču za suradnike.
Povratne informacije o proizvodu .NET
.NET je projekt otvorenog koda. Odaberite vezu za slanje povratnih informacija:
Pridružite se seriji susreta kako biste s kolegama programerima i stručnjacima izgradili skalabilna rješenja umjetne inteligencije temeljena na stvarnim slučajevima upotrebe.