Complete Csharp fundamentals for version >1
Complete Csharp Fundamentals By Sagar Jaybhay
C# first introduced in July 2000 and released in 2002
During the development of the language, it was named Cool.
History Link – Version History
C# is object-oriented, type-safe programming language. C# is used for desktop, web application, mobile application, web API widely used programming language.
C# provides component oriented programming.
C# developed by Microsoft under the .net framework.
It is evolved or has programming concepts based on C, C++, and Java.
Link to download: – https://visualstudio.microsoft.com/vs/community/
.cs is file extension means file contains c sharp code.
To compile code from command line use CSC filename.cs command and for running purpose .exe file with same as the file name is created and only placed filename.exe I will run the program.
C# we strongly typed language and case sensitive programming language.
.Net is a development platform which supports multiple programming languages like c#, F#
.Net framework is a software framework.
You can write a program in C# to develop a business application personal application which runs the on.Net framework
The mainly.net framework consists of CLR (Common Language Runtime) and FCL (Framework Class Library).
Installation Path: – C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework
IL (Intermediate Language) –
It is partially compiled or half compile the code.
So what is need of Il code?
So when you develop an application you don’t know on which machine it will run or on which os version, CPU configuration you don’t know. So .net makes IL code.
- you write the code in c#, F# ,VC++,VB .net or .net compatible language.
- Compiler-like cse.exe, vbc.exe compiler compiles these code in half compile code or partially compiled.
- Then .net execution engine gives these half compile code to CLR common language runtime gives to JIT (just in time) compiler then JIT read every line by line of the code and convert it into platform-specific instruction or we can say it converts into a binary format which machine can execute. The machine doesn’t understand you half English code it read only 1 & 0.
- Then instruction gets executed.
CLR (Common Language Runtime)
CLR is an execution environment for.Net application. It is the heart of the .net framework.
- Garbage collection – background thread is running and see’s which object is not in use then reclaim its memory.
- Code verification – permission checks for application
- IL to Native translation
It brings life to the application by providing your environment.
Mainly it manages your application for running and after your application competition.
It manages your application by providing services like Garbage collection or Memory management. It virtualizes your application means it’s most of the time your application runs on any operating system without your consideration.
Means you need not to worry about how many CPU cores are present or what kind of instruction set it uses for running your application.
CTS (Common Type System)
The .Net framework uses many language vc++, vb .net, c#, F# there might be a situation where we need to call one language application to another so CTS helps for that by enabling cross-language integration, type safety, and high-performance code execution
Defines rules that languages must follow, which helps ensure that objects written in different languages can interact with each other.
Provides primitive type lib like int, Boolean, char
C# has int Data Type and VB.Net has Integer Data Type. Hence a variable declared as an int in C# or Integer in vb.net, finally after compilation, uses the same structure Int32 from CTS.
CLS (common language specification)
It is set of specification rules to be followed
CLS stands for Common Language Specification and it is a subset of CTS. It defines a set of rules and restrictions that every language must follow which runs under the .NET framework. The languages which follow these set of rules are said to be CLS Compliant. In simple words, CLS enables cross-language integration or Interoperability.
- if you take C-Sharp and VB.net in C# each and every statement must have to end with a semicolon it is also called a statement Terminator but in VB.NETeach and every statement should not end with a semicolon(;).
Explanation of the above Example
So these syntax rules which you have to follow from language to language differ but CLR can understand all the language Syntax because in.NET each language is converted into MSIL code after compilation and the MSIL code is language specification of CLR.
FCL (Framework Class Library)
FCL is a standard library which is defined by Common Language Infrastructure. FCL is a collection of reusable classes, interfaces, and value types.
FCL contains code which you use to build your application. Ex. Read-write data from disk, regular expression, IO operation
BCL is called Based class Library which is the core of FCL which provides the most fundamental functionality like System.