All rules
IDE0230Language rules (expression-level preferences)
Use UTF-8 string literal
Use UTF-8 string literal
Microsoft docsDescription
This rule flags the use of a byte array (byte[]) where a UTF-8 string literal could be used instead. Using a UTF-8 string literal adds clarity to the declaration.
Example
// Code with violations.
ReadOnlySpan<byte> _ = new byte[] { 65, 66, 67 };
// Fixed code.
ReadOnlySpan<byte> _ = "ABC"u8;Configurable options
Vote for the value each option should take in the generated .editorconfig.
csharp_style_prefer_utf8_string_literals default:
trueYour vote
Group results
0 yes 0 no
ConsensusNone (disabled)
Severity preference (yes voters)
Suggestion0
Warning0
Error0