Noah R
Noah R

Reputation: 5477

How do you reference a variable inside the view and a string directly after?

I'm using razor for the engine and need some clarification on displaying some text directly after a variable (without any space).

Example Code:

<p>@variable some text</p>

The above code will work just fine, but what if I wanted to have some text displayed directly after it without combining it into the variable and without any space between them.

Obviously this doesn't work:

<p>@variablesometext</p>

Upvotes: 0

Views: 53

Answers (1)

SLaks
SLaks

Reputation: 887459

You need to use parentheses:

<p>@(variable)sometext</p>

Upvotes: 1

Related Questions