Niraj Singh

Niraj Singh

  • NA
  • 159
  • 16.4k

can i declare variable in controller scope in MVC 5

Nov 23 2019 11:34 AM
Hello All,
 
Can i declare a variable in controller scope in Asp.net Mvc5 application or not?
 For Example:
 
public class EmloyeeController : Controller
{
private readonly IEmployee _employee;
 
public EmployeeController(IEmployee emp){
{
_employee=emp; 
 
}
 
this line gives error that "Method must have return type" where I  have declare a private variable of type IEmployee.

Answers (2)