From the course: C# and .NET Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Formatting numerical data

Formatting numerical data - C# Tutorial

From the course: C# and .NET Essential Training

Formatting numerical data

- [Instructor] Earlier in the course, we saw some examples of how to control the way that data was formatted into strings. And remember that I showed this diagram of how to use formatting codes in string interpolation. Now, at the time, I only focused on alignment and spacing and now we're going to see how to use the other fields in the format string. So when working with numerical data, the format specifier can be used to indicate how a number should be displayed. And some of the format codes are listed here. Now, this isn't a full list, but it's the most common ones. And you can see that there are options, such as number and decimal and percent and currency, and there's some others as well. The precision field indicates what numerical precision should be used in the formatting. So let's take a look at some examples. So here in my code for this example, I'm going to open up the format numbers folder, and open up my code.…

Contents