This style rule concerns the use of C# pattern matching over an as expression followed by a null check. This rule is similar to IDE0260, which flags the use of an as expression followed by a member read through the null-conditional operator.
Options
The associated option for this rule specifies whether to prefer pattern match or an as expression with null checks to determine if something is of a particular type.
For more information about configuring options, see Option format.
Prefer pattern matching to determine if something is of a particular type
false
Prefer as expressions with null checks to determine if something is of a particular type
Default option value
true
C#
// csharp_style_pattern_matching_over_as_with_null_check = trueif (o isstring s) {...}
// csharp_style_pattern_matching_over_as_with_null_check = falsevar s = o asstring;
if (s != null) {...}
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 IDE0019// The code that's violating the rule is on this line.#pragmawarning restore IDE0019
To disable the rule for a file, folder, or project, set its severity to none in the configuration file.
ამ შიგთავსის წყაროს მოძიება GitHub-ზე არის შესაძლებელი, სადაც თქვენ ასევე შეგიძლიათ პრობლემების შექმნა და განხილვა და მოთხოვნების გადმოტანა. დამატებითი ინფორმაციისთვის იხილეთ ჩვენი დამხმარე სახელმძღვანელო.
.NET-(ი)ს უკუკავშირი
.NET არის ღია წყაროს პროექტი. აირჩიეთ ბმული უკუკავშირის გასაგზავნად:
შემოუერთდით Meetup სერიას, რათა შექმნათ მასშტაბური AI გადაწყვეტილებები რეალურ სამყაროში გამოყენების შემთხვევებზე დაყრდნობით თანამემამულე დეველოპერებთან და ექსპერტებთან.