i am trying to send integer value from controller to view and display in view multiplied by 0.2

here the code in controller

public ActionResult Details()

        ViewBag["salary"] = 1400;
        return View();

and the code in view

Layout = null;

   int Salary=int.Parse(@ViewBag["salary"]);

<!DOCTYPE html>
    <meta name="viewport" content="width=device-width" />
        <p> Salary: </p>
        @(Salary / 0.2)

but it throw an exception

An exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in System.Core.dll but was not handled in user code

Additional information: Cannot apply indexing with [] to an expression of type 'System.Dynamic.DynamicObject'

Related posts

Recent Viewed