All rules
IDE0062Language rules (modifier preferences)
Make local function static
Make local function static
Microsoft docsDescription
This style rule flags local functions that can be marked static. Marking them as static prevents local variables from being captured, which would result in a memory allocation.
Example
// csharp_prefer_static_local_function = true
void M()
{
Hello();
static void Hello()
{
Console.WriteLine("Hello");
}
}
// csharp_prefer_static_local_function = false
void M()
{
Hello();
void Hello()
{
Console.WriteLine("Hello");
}
}Configurable options
Vote for the value each option should take in the generated .editorconfig.
csharp_prefer_static_local_function default:
true:suggestionYour vote
Group results
0 yes 0 no
ConsensusNone (disabled)
Severity preference (yes voters)
Suggestion0
Warning0
Error0