Reputation: 9725
I have a BaseController as follows:
public class BaseController : Controller
{
string ApplicationName;
public BaseController(string applicationName)
{
ApplicationName = applicationName;
}
}
The question is how can I pass a string as a parameter for the BaseController when it is inherited by the CSController, e.g.
public class CSController : BaseController{"CustomerSite"}
{
}
Upvotes: 2
Views: 51
Reputation: 7187
You can call the base class constructor from your own constructor like this:
public class CSController : BaseController
{
public CSController()
: base("CustomerSite")
{
}
}
Upvotes: 1
Reputation: 27871
You can pass parameters to the base class constructor from the derived class constructor like this:
public class CSController : BaseController
{
public CSController()
:base("CustomerSite")
{
}
}
Upvotes: 2