All rules
IDE0057Language rules (expression-level preferences)
Use range operator
Use range operator
Microsoft docsDescription
This style rule concerns the use of the range operator (..), which is available in C# 8.0 and later.
Example
// csharp_style_prefer_range_operator = true
string sentence = "the quick brown fox";
var sub = sentence[0..^4];
// csharp_style_prefer_range_operator = false
string sentence = "the quick brown fox";
var sub = sentence.Substring(0, sentence.Length - 4);Configurable options
Vote for the value each option should take in the generated .editorconfig.
csharp_style_prefer_range_operator default:
trueYour vote
Group results
0 yes 0 no
ConsensusNone (disabled)
Severity preference (yes voters)
Suggestion0
Warning0
Error0