C Sharp (C#) - Strings and StringBuilder
Which of the following is the correct syntax for formatting a double value to show two decimal places using string interpolation in C#?
:0.00 formats numbers to two decimals.{price:0.00}. double price = 9.99; string s = $"Price: {price,2}"; uses comma which is for alignment, not decimals. double price = 9.99; string s = $"Price: {price:.2f}"; uses Python style .2f which is invalid in C#. double price = 9.99; string s = $"Price: {price.ToString("0.00")}"; calls ToString inside interpolation but with escaped quotes incorrectly.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions