3 ms·
`column.Substring(1, column.Length - 2)` could use the new-ish range indexing syntax. column[1..^1]
by recursive 3y ago
`column.Substring(1, column.Length - 2)` could use the new-ish range indexing syntax.
column[1..^1]
- vilark 3y agoThanks... I didn't think that would compile on .net 6, but it does!
- ygra 3y agoYou can probably shorten it to column[1..] and it compiles down to a Substring call, and ranges are part of C# 8, so they exist since .NET Core 3.1. But even if the syntax is newer (e.g. collection expressions in C# 12) you can often also use features on older target frameworks if they don't require additional runtime support (and even that can often be retrofitted internally).
- recursive 3y agoThat's different. It includes the last character.
- vilark 3y agoFYI I got rid of this line, now I just don't add the quotes in the first place, unless the caller requests it. Performance didn't actually change, but it looks smarter. Thanks again for the review though.