I just installed the free version of the .NET Visual Web Developer 2010 IDE along with version 3 of the ASP.NET MVC framework. I’m new enough to C#, .NET, ASP.NET’s MVC Framework that I’m a little confused by the base controller class that was generated for me, and what’s a C# language feature vs. possible syntactic sugar being provided by the framework
Namespace MvcApplication1
Public Class Default1Controller
Inherits System.Web.Mvc.Controller
'
' GET: /Default1
Function Index() As ActionResult
Return View()
End Function
End Class
End Namespace
Specifically,
-
In the tutorials I’ve found online, a
:is used to indicate inheritance, but here it’s actually the wordInherits. DoesInheritsconfer any addition context/features, or is it just another way of saying:? -
The generated
Indexmethod has no return type, or access modifiers. I was under the impression that these were a required part of the method signature in C#. Is this an incorrect assumption? If so, what is the default return type? -
Also related to the
Indexmethod is the trailingas ActionResult, which sort of looks like a return type for the method signature, but is obviously something else. What does this do? -
Are the above differences in the language something that C# is providing me, or is this syntax simplification something that the ASP.NET MVC framework is giving me via meta-programming?
Full answers are great, but a pointer towards a tutorial or reference that doesn’t assume knowledge of the ASP.NET ecosystem and would get ac experienced programming
It looks like you selected the wrong language if you wanted to use C#. You have posted Visual Basic code.
Inherits. The C# equivalent to this is the colon (:)public ActionResult Index(){
return View();
}
ActionResultis the return type (or a class that inheritsActionResult) that the method will return.