Fork me on GitHub
TypeName NameOfAnalyzer
Check Id CC0021
Category Design
Severity Warning

Cause

In C#6 the nameof() operator should be used to specify the name of a program element instead of a string literal as it produce code that is easier to refactor.

Example

void Foo(string b)
{
	var whatever = "b";
}

Code fix

A code fix will be presented to you that will transform the code:

void Foo(string b)
{
	var whatever = nameof(b);
}

Code fix

Related rules

None

See also

TBD