课程: Learning C#

今天就学习课程吧!

今天就开通帐号,24,600 门业界名师课程任您挑!

String formatting

String formatting

- [Instructor] All right, let's take a deeper look at Formatting Strings. So here in the formatting folder I'm going to open up the program CS file. So far during this course, I've been using the curly brace with index notation to print strings with the values of variables inserted into them. And that's similar to what I have here in my code when I'm printing the strl one variable on this line. Now we can use the same mechanism to get more control over how data is formatted into the string. And the general format for doing this is by specifying the index, which is what we've been doing. And you can see that this is the general format right here. So we specify the index along with an optional alignment value which we'll talk about in a little bit and then a colon and then a format specifier. So we'll take a closer look at the alignment in a moment but for now we'll just focus on the formatting and there are several formatting…

内容