0

I have an string interpolation like below:

$"{PREFIX}{Path.AltDirectorySeparatorChar}{Path.AltDirectorySeparatorChar}{Path.AltDirectorySeparatorChar}{SUFIX}"

Is there any way to avoid repeating the same {Path.AltDirectorySeparatorChar} several times?

Willy
  • 9,848
  • 22
  • 141
  • 284
  • 1
    `$"{PREFIX}{new string(Path.AltDirectorySeparatorChar, 3)}{SUFFIX}"`? or `string.Join(Path.AltDirectorySeparatorChar, PREFIX, string.Empty, string.Empty, SUFFIX);` – juharr Feb 17 '22 at 18:50
  • 1
    The first one works because it's a single `char`, if you needed to repeat a string of characters then the second one would be the way to go. – juharr Feb 19 '22 at 14:32
  • @juharr thx for the clarification. – Willy Feb 19 '22 at 19:25

0 Answers0