Skip to content

CC6494: Update interpolated-strings.md #41 [AUTOMATED] #3456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 19, 2017
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ Used to construct strings. An interpolated string looks like a template string
The arguments of an interpolated string are easier to understand than a [composite format string](../../../standard/base-types/composite-formatting.md#composite-format-string). For example, the interpolated string

```csharp
Console.WriteLine($"Name = {name}, hours = {date:hh}");
Console.WriteLine($"Name = {name}, hours = {hours}:hh");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change introduced a coding error:

{hours}:hh

should be:

{hours:hh}

Otherwise, the variable won't be formatted correclty.

```
contains two interpolated expressions, '{name}' and '{date:hh}'. The equivalent composite format string is:
contains two interpolated expressions, '{name}' and '{hour:hh}'. The equivalent composite format string is:

```csharp
Console.WriteLine("Name = {0}, hours = {1:hh}", name, date);
Console.WriteLine("Name = {0}, hours = {1}:hh", name, hours);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above. This should be:

{1:hh}

```

The structure of an interpolated string is:
Expand Down