Intro to C#

You can create an ASP.NET MVC application using either Visual Basic or C#. For many developers, C# is the preferred language, and that's what we'll use in this lesson. Our sample MVC site is written in C#, too.

C# is an object-oriented programming language. As the name suggests, object-oriented programming is a conceptual model organized around the idea of objects. An object is a container for data and functionality. An object instantiates a class, and a class encapsulates methods, properties, and other data. You can think of the relationship between classes and objects like this: "Dog" is a class; "Fido" is an object instantiating the class "Dog." Or, to put it another way, the object "Fido" is an instance of the class "Dog."

Objects can be set with different access levels. The data available inside an object is not necessarily accessible from outside the object. Access modifiers such as public and private indicate the access level, or scope, of an object's data and determine whether or not that data can be manipulated by other objects.

C# is a compiled language, meaning that it's compiled to machine code before processing. Conversely, scripted languages such as JavaScript and XSLT aren't compiled until runtime. Scripted languages are loosely typed. You can change objects on the fly. In C#, this is not the case. C# is a strongly typed language in which objects have a certain behavior before runtime, and that behavior doesn't change. Scripted languages can be difficult to debug because they don't throw errors until runtime. C#, on the other hand, will throw an error during compilation, prior to runtime.