C# Basic Fundamentals
C# Basic Fundamentals
Topics:
C# vs .NET
CLR (Common Language Run-time)
Architecture of .NET Applications
Our First C# Applications
1. C# FUNDAMENTALS
C# VS .NET
C# is a programming language
.NET is a framework for building applications on windows
.NET framework is not limited to C#
There are different languages that can target C# and build applications using that framework
(examples are F sharp and vb.net)
__________________________________________________________________________________
.NET
CLR (Common Language Runtime)
Class Library
History of C#
Before C# we had C/C++
When we compiled our application, the compiler translated our code directly into the native
code for the machine on which it was running
It would not run on different machine with different architecture & hardware
So, while designing C# and .NET framework the developers borrowed a concept from JAVA
community
In JAVA when you compile your code, it’s not translated directly into the machine code, it’s
translated into an intermediate language called “Bytecode”
We have the exact same concept in C#, when we compile our C# code the result is what we
call IL Code or Intermediate language code, which is independent of the computer on which
it’s running
Now we need something that would translate that IL Code into the native code of the
machine that is running the application and that is the job of CLR or Common Language
Runtime
Definition of CLR: It is essentially an application that is sitting in the memory
whose job is to translate the IL Code into the machine code and this process
is called “JUST-IN-TIME” compilation or “JIT”
2. C# FUNDAMENTALS
Architecture of .NET Applications
At a very high level when we build an application with C# application consists of building
blocks called ”CLASSES”
These classes collaborate with each other at runtime and as a result the application provides
some functionality
Class:
Class consists of attribute also known as data and functions also know as methods
Data represents the state of an application
Methods execute codes, they do things for us
For example, in a car the make, model and colour is it’s Data and the function that is start
and move is the method
In an application there are 10, 100 and even 1000 of classes, each responsible of different
functionality
An example of that is, classes that are responsible for getting the data from the user, process
the data and display something to the user
As the number of classes grows, we need something to organise these classes, that’s where
we use a namespace
Namespace:
Assembly: