Skip to content

String Interpolation Missing '$' #45787

Closed
@tjmccoy

Description

@tjmccoy

Type of issue

Typo

Description

Consider the following code snippet from example 3:

public static void Main(string[] args)
{
Square square = new Square("red", 5);
Console.WriteLine("Area of the square: {square.CalculateArea()}");
}

The Console.WriteLine statement is missing '$' to use string interpolation, so the area is not being printed, but rather "{square.CalculateArea()}".

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/abstract

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/language-reference/keywords/abstract.md

Document Version Independent Id

8c00f924-bf5a-a748-331d-3809321e5547

Platform Id

b426e06e-544c-bc49-3357-dfe8e7916acc

Article author

@BillWagner

Metadata

  • ID: c00e23c2-618d-0b84-8ea8-0b0b4de1101a
  • PlatformId: b426e06e-544c-bc49-3357-dfe8e7916acc
  • Service: dotnet-csharp
  • Sub-service: lang-reference

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions