String.Format with variable names instead of numbers

I read a few posts with some native implementations of this, but I think that now in ASP.NET MVC there should be some method that should have this functionality.

I assume that there is some method that can do what string.Format does:

 string.Format("example {0}", 1);

but instead of using {0}, it can work with variable names just like MVC routes. eg:

 string.Format("example {id}", 1);

Is there such an open method in ASP.NET MVC?

[ Edit: Any idea, such as action links derived from routes?]

+3
source share
3 answers

, v2 1, ASP.NET MVC . .NET Framework.

0

, , .NET 3.5...

string.format .

, . SO. Brilliant!

+1

Visual Studio 2015, Interpolated Strings ( , , .net, ).

:

string txt = $"{person.ForeName} is not at home {person.Something}"; 

, , , ,

0

Source: https://habr.com/ru/post/1717756/


All Articles