Reputation:
does anybody have an idea why following code outputs 1000% for RebatePercent=10 :
return RebatePercent > 0 ? $"{RebatePercent.ToString("0%")}" : "-";
I didn't find anything to output 10%
thx
Upvotes: 2
Views: 236
Reputation: 37299
If you want to keep the use of string interpolation then you can just:
return RebatePercent > 0 ? $"{RebatePercent.ToString()}%" : "-";
Upvotes: 2
Reputation: 14389
you can use as:
RebatePercent > 0 ? String.Format("{0}%", RebatePercent) : "-";
and in C#6:
RebatePercent > 0 ? $"{RebatePercent}%" : "-";
Upvotes: 2