συμβάν
17 Μαρ, 9 μ.μ. - 21 Μαρ, 10 π.μ.
Συμμετάσχετε στη σειρά meetup για να δημιουργήσετε κλιμακούμενες λύσεις AI που βασίζονται σε πραγματικές περιπτώσεις χρήσης με συναδέλφους προγραμματιστές και ειδικούς.
Εγγραφή τώραΑυτό το πρόγραμμα περιήγησης δεν υποστηρίζεται πλέον.
Κάντε αναβάθμιση σε Microsoft Edge για να επωφεληθείτε από τις τελευταίες δυνατότητες, τις ενημερώσεις ασφαλείας και την τεχνική υποστήριξη.
Property | Value |
---|---|
Rule ID | IDE0210 |
Title | Convert to top-level statements |
Category | Style |
Subcategory | Language rules (code-block preferences) |
Applicable languages | C# 9+ |
Options | csharp_style_prefer_top_level_statements |
This rule flags the use of a Main
method entry point in a project that could be converted to top-level statements instead. A candidate method must meet the following requirements:
static
.Main
.public
, doesn't derive from another type or implement an interface, isn't a nested type, and has no attributes or documentation comments.Options specify the behavior that you want the rule to enforce. For information about configuring options, see Option format.
Property | Value | Description |
---|---|---|
Option name | csharp_style_prefer_top_level_statements | |
Option values | true |
Prefer top-level statements. |
false |
Disables the rule. | |
Default option value | true |
// Code with violations.
internal class Program
{
private static void Main(string[] args)
{
Console.WriteLine("Hello world.");
}
}
// Fixed code.
Console.WriteLine("Hello world.");
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 IDE0210
// The code that's violating the rule is on this line.
#pragma warning restore IDE0210
To disable the rule for a file, folder, or project, set its severity to none
in the configuration file.
[*.{cs,vb}]
dotnet_diagnostic.IDE0210.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.
.NET σχόλια
.NET είναι ένα έργο ανοιχτού κώδικα. Επιλέξτε μια σύνδεση για να παρέχετε σχόλια:
συμβάν
17 Μαρ, 9 μ.μ. - 21 Μαρ, 10 π.μ.
Συμμετάσχετε στη σειρά meetup για να δημιουργήσετε κλιμακούμενες λύσεις AI που βασίζονται σε πραγματικές περιπτώσεις χρήσης με συναδέλφους προγραμματιστές και ειδικούς.
Εγγραφή τώρα