gurehbgui
gurehbgui

Reputation: 14684

TryGetValue() in Razor

I want to make a TryGetValuein my ASP.NET MVC3 Razor view, the code looks like this:

@var out;
@Model.Dic.TryGetValue(1, out);
<script type="text/javascript">alert(@out);</script>

I'm getting an error CS0839: Missing Argument. and i dont know why

EDIT Now I changes it to:

@var myOut;
@Model.Dic.TryGetValue(1, out myOut);
<script type="text/javascript">alert(@myOut);</script>

Now I get: "var" is not available in this context.

Upvotes: 0

Views: 1061

Answers (1)

Satpal
Satpal

Reputation: 133403

try this, based on understanding. I have not executed it.

@{
  var myOut;
  Model.Dic.TryGetValue(1, out myOut);
}
<script type="text/javascript">alert(@myOut);</script>

Upvotes: 1

Related Questions