You cannot use C# Objects directly in JavaScript. What you are trying to do is something like this.
On Server
--> Get the object & assign it to list.
--> create a script where line is var a = value of @list[0].Answer1
On Client
--> Try to run a = value of @list[0].Answer1
This doesn't work. Instead, you need to parse the list
to JSON or JS Array. So, it will be something like this.
var jsList = JSON.parse('@Html.Raw(Json.Serialize(list))');
var i = 0;
var qustid = 0;
function aaa() {
var a = jsList[i].Answer1;
alert(a);
qustid = 22;
i = i + 1;
}
I'm assuming you need all the answers on client side and after calling aaa()
you need to display next answer.
This is for converting C# array to JS Array.
How do I convert a C# List<string[]> to a Javascript array?
Edit:
Json.Encode
is not supported in .NET Core. Instead use Json.Serialize()
updated the above code.