C# Fundamentals: Overview of the C# and the .NET Framework

C# has been around for at least 12 years now. It was initially released in 2002. Since that time, the language has grown and matured. We’re on version 5.0 and 6.0 is coming out soon.

Design Goals

C# had very specific design goals in mind. It was to be simple, modern, object-oriented, support strong type and array bounds checking, and automatic garbage collection.

Benefits of the .NET Platform

.NET is the framework, and C# is the language. Well, that’s not entirely true: .NET is definitely the framework and C# is definitely a language that runs on top of it, but the framework supports more! I like to think of .NET as a city and the languages that run on it as different houses that depend on the services .NET provides. There are several languages that run on top of .NET: C#, VB.NET, and F#. There are more, but those are the ones that come out of the box.

So what does .NET afford us the ability to do? Well, since it manages all of our infrastructure for us, we don’t have to worry about pointers (for any of you coming from a C/C++ background): .NET has automatic garbage collection. The CLR manages this for us.

You can also mix and match languages in a project. If you have a VB.NET class you want to include in a C# project, you most certainly can do that. You can even extend that class. It also works in reverse! This is called the Common Type System, or CTS for short.

.NET contains a set of libraries, called Base Class Libraries (or BCL), that abstracts away all of the low level API calls for us, in managed code.

Main Features of .NET

The core features of the .NET framework are:

  • The Common Language Runtime (aka CLR) – This is the runtime layer that takes care of a lot of things like:
              • Locating objects
              • Loading objects
              • Managing objects
              • Managing memory
              • Coordinating threads
              • etc.
  • The Common Type System (aka CTS) – This defines all possible data types and programming constructs supported by the runtime. It also specifies how these things are allowed to interact with each other, and details on how they are represented in the metadata.

We will cover these in detail in future posts when we get into reflection.

Main Features of C#

C# has a lot of cool features, but the most important ones are below:

  • Strong Typing – This is a feature that enforces types across the application. For example, if I am sending an int into a method that expects a string, then I will get an error at compile time. A language that does not have strong typing (weak typing) would just do an implicit type conversion.
  • Simple – The CLR manages things for us and abstracts away all of the low level calls we would have to make in  COM application. We can handle data very easily (as we’ll see in a future post!), and we don’t have pointers! (Pointers were the bane of my existence back in college)
  • Modern – C# is always up to date with the current trends. That can be said about the language, but if you look into the fact that they are shying away from Web Forms and encouraging MVC more, you can definitely tell that they are striving to be current. The language itself, though, is always up to date.
  • Type Safe – Thanks to the CLR, it can only access memory locations that it has permission to execute.
  • Interoperability – You can write code that makes calls to COM, VB.NET, F#, etc.
  • Object-Oriented – In C#, everything is an object. As a matter of fact, even primitive types, well, everything, inherits from the Object base class.
  • Single Inheritance – You can inherit from one and only one class, but you can implement multiple interfaces

In Summary

Released in 2002, C# has come a long way. Since the .NET framework abstracts away all of the low level API calls, we can easily, and quickly, create applications that just work.

Resources

Wikipedia C Sharp (programming language)

Visual Studio 2013 Community

In the next post, we will cover types and take a look at a demo application in Visual Studio 2013 Community!

Advertisements

One thought on “C# Fundamentals: Overview of the C# and the .NET Framework

  1. Not sure but I tend to think of type-safe more along the lines of strong typing as you listed first and not specifically with memory protection. I’m sure C# and .NET provide a memory protection layer but I didn’t think that was related to types specifically. Of course I’m a newbie to .NET so I may be in error.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s