Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi
Im trying to print a variable, but I get the error:
error CS0103: The name 'hey' does not exist in the current context
@if(Model.NodeTypeAlias=="Produktion"){ var hey = "Hey Production"; }else if(Model.NodeTypeAlias=="Logistik"){ var hey = "Hey log"; }else{ var hey = "Hey you"; }<p>@hey</p>
What am I dooing wrong?
/Kate
Hi Kate,
You just need to declare your variable before your if
@{ var hey = string.Empty; } @if(Model.NodeTypeAlias=="Produktion"){ hey = "Hey Production"; }else if(Model.NodeTypeAlias=="Logistik"){ hey = "Hey log"; }else{ hey = "Hey you"; } <p>@hey</p>
Jeavon
@{ var hey = ""; } @if(Model.NodeTypeAlias=="Produktion"){ hey = "Hey Production"; }else if(Model.NodeTypeAlias=="Logistik"){ hey = "Hey log"; }else{ hey = "Hey you"; } <p>@hey</p>
declare hey before the if statement so it is still in scope after the if statement
Hey Kate,
string hey = "Hey production"; if(CurrentModel.NodeTypeAlias=="Producktion"){ @hey } Or
if(Model.Where("NodeTypeAlias == \"Producktion\"")){ @hey }
Great, Thanks
I tried it, but I just wrote:
@{ var hey = "";}
Now I know how to do it.
Thanks
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Simpel variabel problems
Hi
Im trying to print a variable, but I get the error:
error CS0103: The name 'hey' does not exist in the current context
What am I dooing wrong?
/Kate
Hi Kate,
You just need to declare your variable before your if
Jeavon
declare hey before the if statement so it is still in scope after the if statement
Hey Kate,
Great, Thanks
I tried it, but I just wrote:
Now I know how to do it.
Thanks
is working on a reply...