Događaj
Izgradite inteligentne aplikacije
17. mar 21 - 21. mar 10
Pridružite se seriji sastanaka kako biste izgradili skalabilna AI rešenja zasnovana na stvarnim slučajevima korišćenja sa kolegama programerima i stručnjacima.
Registrujte se odmahOvaj pregledač više nije podržan.
Nadogradite na Microsoft Edge biste iskoristili najnovije funkcije, bezbednosne ispravke i tehničku podršku.
Property | Value |
---|---|
Rule ID | IDE0075 |
Title | Simplify conditional expression |
Category | Style |
Subcategory | Language rules (expression-level preferences) |
Applicable languages | C# and Visual Basic |
Options | dotnet_style_prefer_simplified_boolean_expressions |
This style rule concerns simplifying conditional expressions that return a constant value of true
or false
versus retaining conditional expressions with explicit true
or false
return values.
Options specify the behavior that you want the rule to enforce. For information about configuring options, see Option format.
Property | Value | Description |
---|---|---|
Option name | dotnet_style_prefer_simplified_boolean_expressions | |
Option values | true |
Prefer simplified conditional expressions |
false |
Do not prefer simplified conditional expressions | |
Default option value | true |
// dotnet_style_prefer_simplified_boolean_expressions = true
var result1 = M1() && M2();
var result2 = M1() || M2();
// dotnet_style_prefer_simplified_boolean_expressions = false
var result1 = M1() && M2() ? true : false;
var result2 = M1() ? true : M2();
' dotnet_style_prefer_simplified_boolean_expressions = true
Dim result1 = M1() AndAlso M2()
Dim result2 = M1() OrElse M2()
' dotnet_style_prefer_simplified_boolean_expressions = false
Dim result1 = If (M1() AndAlso M2(), True, False)
Dim result2 = If (M1(), True, M2())
If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.
#pragma warning disable IDE0075
// The code that's violating the rule is on this line.
#pragma warning restore IDE0075
To disable the rule for a file, folder, or project, set its severity to none
in the configuration file.
[*.{cs,vb}]
dotnet_diagnostic.IDE0075.severity = none
To disable all of the code-style rules, set the severity for the category Style
to none
in the configuration file.
[*.{cs,vb}]
dotnet_analyzer_diagnostic.category-Style.severity = none
For more information, see How to suppress code analysis warnings.
Povratne informacije za .NET
.NET je projekat otvorenog koda. Izaberite vezu da biste pružili povratne informacije:
Događaj
Izgradite inteligentne aplikacije
17. mar 21 - 21. mar 10
Pridružite se seriji sastanaka kako biste izgradili skalabilna AI rešenja zasnovana na stvarnim slučajevima korišćenja sa kolegama programerima i stručnjacima.
Registrujte se odmah