Unexpected “string” keyword after “@” character. Once inside code, you do not need to prefix constructs like “string” with “@”.

One feature of the Razor Engine which is intended to assist developers is the built in ability to implicitly interpret the server code from the client markup. For the most part it works well but there may be some instances where the engine is unable to do this and a little help from the developer is needed. If you receive the following error this may be one of those times

Unexpected “string” keyword after “@” character. Once inside code, you do not need to prefix constructs like “string” with “@”.

There are a couple of detailed articles by Scott Guthrie explaining how Razor separates the code blocks from the page markup.

ASP.NET MVC 3: Implicit and Explicit code nuggets with Razor

ASP.NET MVC 3: Razor’s @: and syntax

Here is an example of code that would product the above error

@if (Model.Products[counter].Depots.ContainsKey(d))
{
    @string.Join(", ", Model.Products[counter].Depots[d].ToArray())
}

In short Razor looks for tags in the code block, in the above code the @if statement starts a code block. This block does not have any tags, only a code nugget (single line of code) where an @ sign indicates the start of a another code block. Razor sees the @ starting the second code block as unnecessary. If you were to remove the @ altogether on the @string.Join line Razor would see this line as C# server code and expect the line to be followed by a semicolon (;).

@if (Model.Products[counter].Depots.ContainsKey(d))
{
    string.Join(", ", Model.Products[counter].Depots[d].ToArray());
}

Now your application will run without exception but this modified line will not render any output to the view as it will be seen as code where the string returned by the Join method is not assigned to a variable or anything.
There are two key solutions.
Solution 1
Wrap the content line around tags

<span>
@string.Join(", ", Model.Products[counter].Depots[d].ToArray())
</span>

Solution 2
Wrap the line in an element to explicitly identify the content.

<Text>@string.Join(", ", Model.Products[counter].Depots[d].ToArray())</Text>

A element can contain a mix of text and code nuggets. so this will also work for both solutions,

<Text>This is a depot @string.Join(", ", Model.Products[counter].Depots[d].ToArray())</Text>

Make sure to read the articles mentioned for additional information.