convert c# array to javascript array razor code example
Example: viewdata array mvc razor javascript
// For ASP.NET
var monthLists = @Html.Raw(Json.Encode(ViewData["months"]));
// For ASP.NET CORE
var monthLists = @Html.Raw(Json.Serialize(ViewData["months"]));