What is the difference between C# and .NET?
In addition to what Andrew said, it is worth noting that:
- .NET isn't just a library, but also a runtime for executing applications.
- The knowledge of C# implies some knowledge of .NET (because the C# object model corresponds to the .NET object model and you can do something interesting in C# just by using .NET libraries). The opposite isn't necessarily true as you can use other languages to write .NET applications.
The distinction between a language, a runtime, and a library is more strict in .NET/C# than for example in C++, where the language specification also includes some basic library functions. The C# specification says only a very little about the environment (basically, that it should contain some types such as int
, but that's more or less all).
.NET is a framework. What that means is that the .NET platform contains libraries of existing code and architecture from which all applications utilizing it build from. So rather than pouring a new foundation for every house, you already start off with a solid one that has been perfected and improved upon over time. In addition to a starting foundation, the framework serves as a sort of toolbox of existing code that saves you from reinventing the wheel every time you need certain things.
For instance, winforms is an established foundation from which to build windows applications with a rudimentary user interface simply by going to file > new project. You would have to interface with GDI yourself to generate windows forms and user interface if this library of existing code was not there to support you.
C# is simply a programming language. One specifically written with .NET in mind. In fact, most of the .NET framework is written in C# (if not all of it). It's syntax is simply the next progression of the C language, thus transitioning from C++ to C# shouldn't be too difficult. It's a paradigm shift with a lot of things, but at least the syntax is often familiar. Any .NET language is usually compatible with other .NET languages. For instance, I could write a class library in Visual Basic, and you could use that compiled library in your C# program.
Because .NET is a framework, the code you reference in it does not get compiled into your program, rather a reference to code in the framework is all that gets compiled. This means that clients running your program must also have the .NET framework, albeit a stripped down version. They don't need all the development tools that you need so their .NET framework download is a little smaller. Clients running Windows Vista/7 don't need to worry about anything; it's included with their OS. Only certain users running XP would even have to worry about downloading the framework, and most programs accurately detect the requirement and inform the end user to go download it.
All versions of Visual Studio are simply tools to help you build applications and better utilize the .NET framework. I would never recommend coding in any .NET language without at least the express (free) edition of visual studio. Intellisense alone is worth it. That said, it is definitely possible to code something in .NET without the Visual Studio IDE. You could open up notepad right now and write a C# program, compile it with the free compiler, and run it. While Visual Studio 2010 is pretty amazing, and uses the new WPF platform to run, 2008 will serve you just as well. 2010 is optimized for .NET 4 but works just fine when targeting previous versions of .NET as well.
Bottom line:
- .NET is a coding framework.
- C# is a language built to take advantage of .NET. NOTE: Visual Basic is also a .NET language and choosing between C# and VB is simply a matter of preference.
- Visual Studio is a tool to help you in coding for .NET.
That is how they are all related.
Relationship between C#, .NET, ASP, ASP.NET etc
I understand your confusion, believe me I have the same perspective when it comes to the Java world! Anyway I'll attempt to break your questions down and tackle them one by one... as well as add some other points in that will hopefully help clarify what's going on:
- C# and C#.NET are the same thing... C#
- .NET is, as you say, a library of code that .NET languages can talk to.
- .NET languages come in different flavours such as: C#.NET, VB.NET, Managed C++, F#.
- .NET languages compile to CIL (Common Intermediate Language) which means they all start "talking" the same language and can therefore interoperate.
- ASP.NET is the portion of the .NET library used for making web sites. There are other subsections of ASP.NET like WebForms (the old way of making web pages) or the rapidly maturing MVC library that are worth looking at too.
- Forms (old tech) or the new WPF (Windows Presentation Foundation) are the technologies you'd typically use in .NET to create what you know as traditional desktop applications.
One final thing I'd like to finish on is the difference between library and framework. In recent years these two terms have been used as those synonymous, however that is not the case. The easiest way I can think to differentiate the two is:
- A library contains many pieces of functionality that you may pick and choose from i.e. using one piece of technology doesn't mean you're locked into the rest. This means freedom, however you will have more work cut out for you.
- A framework however very much sets out how you will be working be providing a workflow that for better or worse is hard to change. This means rapid development/prototyping, but if significant changes are made in the future it may be impossible (or very time consuming) to implement them.
The project you're working on will depend on which choice you make.