May I know what is the difference between C# and .NET? When I think of C#, right away I would say it is a .NET language, but when I search for job posts, they require candidates to have C# and .NET experience. Can someone give me an explanation?
-
56I can explain the requirements postings... They're written by non-.NET developers. Either HR or management folks who don't NEED to understand the distinction. – David Apr 27 '10 at 20:34
-
2You're absolutely right, I should know between the two. I have been using C# for quite sometime now and always use .Net library class when coding C# but never take time to differentiate between the two. But now I know, thanks.. – Bopha Apr 27 '10 at 20:47
-
1If you have experience in C#, you also have decent experience in .NET. Functions like `Console.Write()` and classes like `List` are part of the .NET library, which means they can also be accessed by other .NET languages like VB.NET. Unless you've been using C# in an unusual way, you can't have one without the other. – InvalidBrainException Aug 18 '20 at 16:40
11 Answers
C# is a programming language, .NET is a blanket term that tends to cover both the .NET Framework (an application framework library) and the Common Language Runtime which is the runtime in which .NET assemblies are run.
Microsoft's implementation of C# is heavily integrated with the .NET Framework so it is understandable that the two concepts would be confused. However it is important to understand that they are two very different things.
Here is a class written in C#:
class Example { }
Here is a class written in C# that explicitly uses a .NET framework assembly, type, and method:
class Example
{
static void Main()
{
// Here we call into the .NET framework to
// write to the output console
System.Console.Write("hello, world");
}
}
As I mentioned before, it is very difficult to use Microsoft's implementation of C# without using the .NET framework as well. My first Example
implementation above even uses the .NET framework (implicitly, yes, but it does use it nonetheless) because Example
inherits from System.Object
.
Also, the reason I use the phrase Microsoft's implementation of C# is because there are other implementations of C# available.

- 344,730
- 71
- 640
- 635
-
3
-
2+1 Andrew Hare. @Tejs: Both C# and VB are heavily integrated to .NET, it is not .NET. .NET is a framework. As per instance, you can do .NET in Delphi. If C# is .NET, then you would be able to code C# in Delphi .NET, which is clearly not doable and even unconceivable. – Will Marcouiller Apr 27 '10 at 20:41
-
Similarly, there's no reason you have to have .NET to program in C#, although I don't know of anybody who writes C# without either .NET or Mono. – David Thornley Apr 27 '10 at 20:50
-
.NET CLR is all about types. In order to support multiple languages, they came up with CTS - Common type system which defines how types must be defined and rules governing them e.g. inheritance, object lifetime etc. C++/CLI, C#, VB are all languages conforming to these types (you could in violate this but I wont get into it). .Regardless of what language you use to construct the type, behavior will be same when executed by .NET CLR. Hence, language and .NET can evolve separately though there is connection via the CTS. VS2012 e.g. not support C# 6 compiler but works with .NET 4.6 – Frank Q. Mar 17 '18 at 06:05
-
2Perhaps editing this answer to include an `Example` class written in VB.NET would drive the point home. I didn't really understand the difference between C# and .NET until I had to work with VB.NET and realised that I could call the typical .NET classes and methods like `Console.Write()` and `List` from VB.NET. Nowadays I think of .NET as the common pool of functions and classes accessible from all .NET languages. You could create a new programming language called **Jellybean.NET**. The syntax would be different, but it would have access to the very same methods and classes. – InvalidBrainException Aug 18 '20 at 16:31
In addition to Andrew's answer, 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).

- 3,777
- 9
- 27
- 53

- 240,744
- 19
- 378
- 553
-
Might be worth adding the definition for *runtime* in the first point (as distinct from the lang/library). Here is a good one: https://stackoverflow.com/a/3900802/6165072 – Haroon Nov 23 '21 at 09:48
C# is a programming language, .NET is the framework that the language is built on.

- 9,665
- 1
- 30
- 38
C# is a strong Object Oriented programming language that is mostly built on the .NET framework.
C# is the airplane and .NET is the runway ;)

- 683
- 5
- 2
C# is a language, .NET is an application framework. The .NET libraries can run on the CLR and thus any language which can run on the CLR can also use the .NET libraries.
If you are familiar with Java, this is similar... Java is a language built on top of the JVM... though any of the pre-assembled Java libraries can be used by another language built on top of the JVM.

- 39,494
- 39
- 114
- 146
-
4
-
6
-
4@KasunSiyambalapitiya CLR used to convert to code to native code I mean you write a code c# the conversion will be like this C# => CLR => Native code. Then it will run all platforms like linux or windows – logeshpalani31 Jul 20 '19 at 17:20
When people talk about the ".net framework" they tend to be combining two main areas - the runtime library and the virtual machine that actually runs the .net code.
When you create a class library in Visual Studio in C#, the DLL follows a prescribed format - very roughly, there is section that contains meta data that describes what classes are included in it and what functions they have, etc.. and that describes where in the binary those objects exist. This common .net format is what allows libraries to be shared between .net languages (C#, VB.Net, F# and others) easily. Although much of the .net "runtime library" is written in C# now (I believe), you can imagine how many of them could have been written in unmanaged languages but arranged in this prescribed format so that they could be consumed by .net languages.
The real "meat" of the library that you build consists of CIL ("Common Intermediate Language") which is a bit like the assembly language of .net - again, this language is the common output of all .net languages, which is what makes .net libraries consumable by any .net language.
Using the tool "ildasm.exe", which is freely available in Microsoft SDKs (and might already be on your computer), you can see how C# code is converted into meta data and IL. I've included a sample at the bottom of this answer as an example.
When you run execute .net code, what is commonly happening is the .net virtual machine is reading that IL and processing it. This is the other side of .net and, again, you can likely imagine that this could easily be written in an unmanaged language - it "only" needs to read VM instructions and run them (and integrate with the garbage collector, which also need not be .net code).
What I've described is (again, roughly) what happens when you build an executable in Visual Studio (for more information, I highly recommend the book "CLR via C# by Jeffrey Richter" - it's very detailed and excellently written).
However, there are times that you might write C# that will not be executed within a .net environment - for example, Bridge.NET "compiles" C# code into JavaScript which is then run in the browser (the team that produce it have gone to the effort of writing versions of the .net runtime library that are written in JavaScript and so the power and flexibility of the .net library is available to the generated JavaScript). This is a perfect example of the separation between C# and .net - it's possible to write C# for different "targets"; you might target the .net runtime environment (when you build an executable) or you might target the browser environment (when you use Bridge.NET).
A (very) simple example class:
using System;
namespace Example
{
public class Class1
{
public void SayHello()
{
Console.WriteLine("Hello");
}
}
}
The resulting meta data and IL (retrieved via ildasm.exe):
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly Example
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyTitleAttribute::.ctor(string) = ( 01 00 0A 54 65 73 74 49 4C 44 41 53 4D 00 00 ) // ...TestILDASM..
.custom instance void [mscorlib]System.Reflection.AssemblyDescriptionAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyConfigurationAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyCompanyAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyProductAttribute::.ctor(string) = ( 01 00 0A 54 65 73 74 49 4C 44 41 53 4D 00 00 ) // ...TestILDASM..
.custom instance void [mscorlib]System.Reflection.AssemblyCopyrightAttribute::.ctor(string) = ( 01 00 12 43 6F 70 79 72 69 67 68 74 20 C2 A9 20 // ...Copyright ..
20 32 30 31 36 00 00 ) // 2016..
.custom instance void [mscorlib]System.Reflection.AssemblyTrademarkAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.InteropServices.ComVisibleAttribute::.ctor(bool) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = ( 01 00 24 31 39 33 32 61 32 30 65 2D 61 37 36 64 // ..$1932a20e-a76d
2D 34 36 33 35 2D 62 36 38 66 2D 36 63 35 66 36 // -4635-b68f-6c5f6
32 36 36 31 36 37 62 00 00 ) // 266167b..
.custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = ( 01 00 07 31 2E 30 2E 30 2E 30 00 00 ) // ...1.0.0.0..
.custom instance void [mscorlib]System.Runtime.Versioning.TargetFrameworkAttribute::.ctor(string) = ( 01 00 1C 2E 4E 45 54 46 72 61 6D 65 77 6F 72 6B // ....NETFramework
2C 56 65 72 73 69 6F 6E 3D 76 34 2E 35 2E 32 01 // ,Version=v4.5.2.
00 54 0E 14 46 72 61 6D 65 77 6F 72 6B 44 69 73 // .T..FrameworkDis
70 6C 61 79 4E 61 6D 65 14 2E 4E 45 54 20 46 72 // playName..NET Fr
61 6D 65 77 6F 72 6B 20 34 2E 35 2E 32 ) // amework 4.5.2
.hash algorithm 0x00008004
.ver 1:0:0:0
}
.module Example.dll
// MVID: {80A91E4C-0994-4773-9B73-2C4977BB1F17}
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x05DB0000
// =============== CLASS MEMBERS DECLARATION ===================
.class public auto ansi beforefieldinit Example.Class1
extends [mscorlib]System.Object
{
.method public hidebysig instance void
SayHello() cil managed
{
// Code size 13 (0xd)
.maxstack 8
IL_0000: nop
IL_0001: ldstr "Hello"
IL_0006: call void [mscorlib]System.Console::WriteLine(string)
IL_000b: nop
IL_000c: ret
} // end of method Class1::SayHello
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method Class1::.ctor
} // end of class Example.Class1
// =============================================================

- 2,244
- 16
- 31
In .NET you don't find only C#. You can find Visual Basic for example. If a job requires .NET knowledge, probably it need a programmer who knows the entire set of languages provided by the .NET framework.

- 3,152
- 2
- 27
- 41
-
1you're absolutely right and thanks for the headup. Although I only mention C# in this question, but in that particular job post, it mentions VB as well.. – Bopha Apr 27 '10 at 20:52
C# is a programming language.
.Net is a framework used for building applications on Windows.
.Net framework is not limited to C#. Different languages can target .Net framework and build applications using that framework. Examples are F# or VB.Net

- 290
- 3
- 12
C#
does not have a seperate runtime library. It uses .NET
as a runtime library.

- 2,353
- 10
- 46
- 70
Here I provided you a link where explain what is C# Language and the .NET Framework Platform Architecture. Remember that C# is a general-purpose, object-oriented programming language, and it runs on the .NET Framework.
.NET Framework includes a large class library named Framework Class Library (FCL) and provides user interface, data access, database connectivity, cryptography, web application development, numeric algorithms, and network communications.
.NET Framework was developed by Microsoft that runs primarily on Microsoft Windows.
Introduction to the C# Language and the .NET Framework from Microsoft Docs

- 2,565
- 2
- 27
- 34
[C#]
Is a language with rules on how you can write code, variables, classes etc, this is only C# with zero .net:
public int SumTwo(int a, int b){ return a + b; }
[.NET]
Is a framework to run programs into an environment, provides a wide list of resources that might be shared across different OS.
See this example with one .NET method:
File.AppendAllText("file.txt", "DEMO CONTENT");
In this example, the C# code will be calling .NET to create a file and add a content, the execution will be different on Linux and Windows but the .NET will take care of these differences letting you use the same contract and don't having to worry about that on C# level.

- 750
- 7
- 23