Custom enum as optional parameter

kvartirag

New Member
\[code\] public enum Employee { FT, PT, }\[/code\]This doesn't work\[code\] public ActionResult Index(Employee s = Employee.PT) { ViewData["Message"] = s.ToString(); return View("MyView"); }\[/code\]\[quote\] Exception Details: System.ArgumentException: The parameters dictionary contains an invalid entry for parameter 's' for method 'System.Web.Mvc.ActionResult Index(SampleControllerEx.Controllers.Employee)' in 'SampleControllerEx.Controllers.HomeController'. The dictionary contains a value of type 'System.Int32', but the parameter requires a value of type 'SampleControllerEx.Controllers.Employee'. Parameter name: parameters\[/quote\]But below one works,\[code\]public ActionResult Index([DefaultValue(Employee.PT)] Employee s) { ViewData["Message"] = s.ToString(); return View("MyView"); }\[/code\]May I know why 'DefaultValue' only supports custom enum, where optional parameter(4.0) doesn't support it?
 
Top