Complete Csharp fundamentals for version >1
Complete Csharp Fundamentals By Sagar Jaybhay
C# firstintroduced in July 2000 and released in2002
During the development of the language, it was named Cool.
History Link – VersionHistory
C# is object-oriented,type-safe programming language. C# isused for desktop, web application, mobile application, web API widely usedprogramming 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 placedfilename.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 softwareframework.
You can write a program in C# to develop a businessapplication personal application which runsthe on.Net framework
The mainly.netframework consists of CLR (CommonLanguage Runtime) and FCL (Framework Class Library).
Installation Path: – C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework
IL (IntermediateLanguage) –
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 theheart of the .net framework.
- Garbage collection – background thread isrunning and see’s which object is not in use then reclaim its memory.
- Code verification – permission checks forapplication
- IL to Native translation
It brings life to the application by providing your environment.
Mainly it manages yourapplication for running and after your application competition.
It manages your application by providing services likeGarbage collection or Memory management. It virtualizesyour application means it’s most of the time your application runs on any operating system without yourconsideration.
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 TypeSystem)
The .Net frameworkuses many language vc++, vb .net, c#, F# there might be a situation where weneed to call one language application to another so CTS helps for that by enablingcross-language integration, type safety, and high-performancecode execution
Defines rules that languages must follow, which helps ensurethat 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 languagespecification)
It is set of specification rules to be followed
CLS stands for Common Language Specificationand it is a subset of CTS. It defines a set of rules and restrictions thatevery language must follow which runs under the .NET framework. The languageswhich 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 ClassLibrary)
FCL is a standard library which is defined by CommonLanguage Infrastructure. FCL is a collection of reusable classes, interfaces, and value types.
FCL contains codewhich you use to build your application. Ex. Read-writedata from disk, regular expression, IO operation
BCL is called Based class Library which is the core of FCL which provides the most fundamentalfunctionality like System.