I have my view as something like the following,
class MyModel
{
...
public IDictionary<string, string> Values {get; set;}
}
@model web.Models.MyModel
@{
// This works
if(Model.Values.ContainsKey("key"))
{
// ta daa
}
// If I include this part, I don't even get to reach the previous code
// because the excpetion is thrown
if(Model.Values.TryGetValue("key", out string myValue))
{
}
}
The problem is if I include the TryGetValue
part, I don't even get to execute any code in my view, because the exception is thrown before I land in to the view.
The error is as follows:
An error occurred during the compilation of a resource required to process
this request. Please review the following specific error details and modify
your source code appropriately.
/Views/MyView.cshtml
Syntax error, ',' expected
if(Model.Values.TryGetValue("key", out string myValue)) <-- I don't see any syntax error