//C# is a type safe language.
In C if we write int a = "21"; then it will not show
any error because C is a type unsafe language.
//C# is an oop's based language.
//C# runs on .NET framework.
//We can create variety of application in c#, like Windows client application, XML
Web servers, distributed component, client server application, database
application, etc.
//C# has some of the cpp features plus it has it's own new concepts like deligates,
lambda expression, direct memory access, also supports generic methods and types,
iterators.
//Also has a unique feature called LINQ(Language Intregrated Query), to access data
from a data source(sql server, xml etc.) we can use it.
//.NET framework = (Common Language Runtime + Libraries)
//Source code in C# will get compiled into an intermediate language(or Microsoft
Intermediate Language) that comfirms to the CLI(Common Language Infrastructure)
specifications.
//In C or CPP we write a source code and then the compiler compiles the code into
machine understanding language. But in the case of C# the compiler doesn't convert
the code to the machine understable language instead it converts the code into an
intermediate language called MSIL.
//Now suppose we have 3 developer in a single project with 3 different languages
like java cpp and c#, they both will write source code for the project into their
respective languages, after that all the codes will be given to CLI, now CLI has
all the 3 compiler for all the 3 different languages, the CLI compiles all the
source code and converts it into a single source code(MSIL), now this final source
code will be run by CLR.
//Now some times our source code may have references or resources like images,
videos etc. This will called an Assembly( means MSIL/IL + Reference, Resources),
the assembly either will be a .exe file( this exe file can't be run in windows, it
can only run in .NET framework) or a .dll file.
//Now assembly contains a manifest that provides information about the assembly
type, version, culture and security requirements.
//When C# program is executed, it will loaded into the CLR, which might take
various actions based on the information in the manifest. If the requirements are
met then the CLR performs Just In Time(JIT) compilation to convert the IL code to
native machine instruction.
//So CLR has JIT compiler also has garbage collection, exception handling, resouce
management system.
//Code that is compiled by the CLR( IL/MSIL) is called managed code. Means managed
code == Assembly == IL/MSIL.
//Multi language support is a key feature of .NET framework.
//CLR also has the libraries that has over 4000+ predefine classes that are
organized in the namespaces.
Difference between C# and C# .NET:
C# is a programming language but .NET is a framework.
Framework: It's a set of both liabraries and best practices that helps us not to
reinvent the wheel, and provide a set of guidelines on how to develop.
Now .NET framework is the above but it also provides some more features, it is also
a platform for developing software, runtime environment and liabraries.
//When we use visual studio IDE to code C# then it's also called as visual C#.
Now when we try to run a C# code it'll need the libraries that are present in .NET
framework.
.NET framework will only work on windows that is a microsoft platform.
.NET core similar to .NET framework but it's for all platforms( linux, mac and
windows).
MONO is also a similar thing like .NET core.
Now .NET core has some more facalities than .NET, so some apps in .NET core may not
run in .NET, so we have .NET standard, if we develop app in .NET standard then the
apps will run in both of the cases.
History of C#:
In 2002 C# was developed by a Microsoft team that is being leaded by Anders
Hejlsberg.
In object oriented programming methods are invoked using object, scenes value type
such as int, long are not object, we can't use them to call method. C# enables us
to achieve this through a technique known as boxing.
Boxing means the conversion of a value type on the stack to a object type on
the heap.
Unboxing means the conversion of an object type into a value type.