In Rider Resharper suggests to simplify string interpolation.
When doing so, the Heap Allocation Viewer plugin warns me about boxing allocation. And indeed, the IL code is different and when running a stopwatch it's clear that the simplified approach is approximately 50% slower.
Two questions:
- Why does Rider suggest this "improvement" when in reality it doesn't result in the same and even less performant code.
- Why doesn't the compiler convert :X8 to ToString(x8) to improve performance? Is there any advantage of :X8?
public string ToHexString1() => $"HexValue is: {uintVariable.ToString("X8")}"; //no boxing allocation
public string ToHexString2() => $"HexValue is: {uintVariable:X8}"; //boxing allocation

