using string.Format in MVC Razor view page

asp.net-mvc, razor

Solution

`string.Format()` returns a string, which you're discarding.

You need to print that string to the page:

@string.Format(...)

Note that since this isn't a statement, there shouldn't be a `;`.

Also note that it would be better to use Razor itself:

<img src="@p.Path" width="100" alt="@p.AlternateText" />  

Problem

I want to render images in a Razor view using `string.Format` like this ... ``` foreach (var p in @Model.Photos) { string.Format("<img src='{0}' width='100' alt='{1}' />", p.Path, p.AlternateText); } ``` Something is clearly wrong here, because on rendering this page, I've got nothing inside this section.

Original source