In the above example, line interpolation is not required. Using the standard razor syntax, you can get the result you want:
<button data-value="@(item.CustomerID) _@item.CustomerType "></button>
What will produce <button data-value="34567_123"></button>
The same with interpolation will be:
@Html.Raw($"<button data-value='{item.CustomerID}_{item.CustomerType}'></button>")
But you lose the HTML encoded to prevent the script from being injected (although this is unlikely for the data types you are dealing with).
Edit:
If you want to be completely stupid, you can mix both.
<button data-value="@($"{item.CustomerID}_{item.CustomerType}")"></button>
But it is more detailed and difficult to read.
source share