@foreach (string s in "1,2,3".Split(',')) {
s is equal to @s<br/>
}
我要吐了出來: s等於1 s等於2 s等於3剃刀語法 - foreach循環
但我發現了各種因視覺誤差的Studio認爲{}之間的內容是代碼,但我希望它是標記。
@foreach (string s in "1,2,3".Split(',')) {
s is equal to @s<br/>
}
我要吐了出來: s等於1 s等於2 s等於3剃刀語法 - foreach循環
但我發現了各種因視覺誤差的Studio認爲{}之間的內容是代碼,但我希望它是標記。
剛看到這個on ScottGu's blog this morning:使用@:
在該行之前:
@foreach (string s in "1,2,3".Split(',')) {
@: s is equal to @s<br/>
}
或者,使用<text />
標籤:
@foreach (string s in "1,2,3".Split(',')) {
<text>s is equal to @s<br/></text>
}
Scott Guthrie just answered that this morning。
將其更改爲
@foreach (string s in "1,2,3".Split(',')) {
@: s is equal to @s<br/>
}
@foreach (string s in "1,2,3".Split(',')) {
<text>s is equal to </text>@s<br/>
}
我想這是因爲你在括號外的解析文本,以便剃刀想它的代碼,請嘗試使用上面的剃刀文本標籤,這種分析完全一樣@ :但(至少對我來說)更直觀一些(它不會解析標籤)
''對多行很好。 –
crush
2014-10-28 17:52:54