In c# defining a class what does :
means?
As example, in this very basic controller of an ASP.NET MVC application:
namespace App.Controllers { public class HomeController : Controller { public ActionResult Index() { return View(); } } }
In the third line, what does : Controller
means?
It's commonly used to pack lots of values into an integral type. In your particular case, it defining the structure of a 32-bit microcode instruction for a (possibly) hypothetical CPU (if you add up all the bit-field lengths, they sum to 32).
The base class is specified by adding a colon, “:”, after the derived class identifier and then specifying the base class name. Note: C# supports single class inheritance only. Therefore, you can specify only one base class to inherit from.
In this case it means that the HomeController
inherits the Controller
class.
You can read more details about inheritance here, but simply put - inheritance means that everything a Controller
is, a HomeController
is also. A HomeController
is a more finely grained Controller
class.
It can also be used for implementation of interfaces http://msdn.microsoft.com/en-us/library/ms173156.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With