String interpolation in Asp.Net MVC

I just came across a reference to string interpolation in Asp.Net MVC. Apparently if you start a string reference with a dollar ($) sign, it will accept curly bracketed arguments, like the following:

@model Hotel
    var mystring = $"The hotel name is:{Model.DisplayName}";

This allows you to put the arguments inside the string. It replaces it with the contents of the argument, which in this case is the display name of the hotel.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: