C# Week 1

Harshit Yadav
5 min readMay 3, 2020

What is Common Type System (CTS) means ?

This data type problem is solved in .NET using the Common Type System (CTS). The CTS defines the predefined data types available in IL so that all languages that target the .NET Framework can produce compiled code ultimately based on these types.

What does Common Language Runtime (CLR) mean?

Common Language Runtime (CLR) is a managed execution environment that is part of Microsoft NET framework. CLR manages the execution of programs written in different supported languages.

CLR transforms source code into a form of bytecode known as Common Intermediate Language (CIL). At run time, CLR handles the execution of the CIL code.

The most important part of the .NET Framework is the .Net Common Language Runtime (CLR) also called .Net Runtime in short. It is a framework layer that resides above the Operating System and handles/manages the execution of the .NET applications. Our .Net programs don’t directly communicate with the Operating System but through CLR.

MSIL (Microsoft Intermediate Language) Code:

When we compile our .Net Program using any .Net compliant language like (C#, VB.NET, C++.NET) it does not get converted into the executable binary code but to an intermediate code, called MSIL or IL in short, understandable by CLR. MSIL is an OS and H/w independent code. When the program needs to be executed, this MSIL or intermediate code is converted to binary executable code, called native code. The presence of IL makes it possible the Cross Language Relationship as all the .Net compliant languages produce the similar standard IL code.

Just In Time Compilers (JITers):

When our IL compiled code needs to be executed, CLR invokes JIT compilers which compile the IL code to native executable code (.exe or .dll) for the specific machine and OS. JITers in many ways are different from traditional compilers as they, as their name suggests, compile the IL to native code only when desired e.g., when a function is called, IL of function’s body is converted to native code; just in time of need. So, the part of code that is not used by particular run is not converted to native code. If some IL code is converted to native code then the next time when its needed to be used, the CLR uses the same copy without re-compiling. So, if a program runs for sometime, then it won’t have any just in time performance penalty. As JITers are aware of processor and OS exactly at runtime, they can optimize the code extremely efficiently resulting in very robust applications. Also, since JITer knows the exact current state of executable code, they can also optimize the code by in-lining small function calls (like replacing body of small function when its called in a loop, saving the function call time).

Why C#

.NET Framework, .NET Standard and .NET Core (link1, link2)

.net assemblies

The .NET assembly is the standard for components developed with the Microsoft.NET. Dot NET assemblies may or may not be executable, i.e., they might exist as the executable (.exe) file or dynamic link library (DLL) file

Namespace and Classes

Class Library

The .NET Framework class library is a library of classes, interfaces, and value types that provide access to system functionality ,link

csproj, .sln file

1: GUIDs are used in enterprise software development in C#, Java, and C++ as database keys, component identifiers, or just about anywhere else a truly unique identifier is required. GUIDs are also used to identify all interfaces and objects in COM programming.

Basically the .csproj file contains the list of files in your project, plus the references to system assemblies etc.

There are a whole bunch of settings — Visual Studio version, project type, Assembly name, Application Icon, Target Culture, Installation Url,…

Everything you need to build your project. While you could assume that you need everything in the current folder, having an explicit list allows you to organise them logically both on the disk and in the project so you can more easily find the files you want.

It’s just XML so you can open it in your favourite text editor and take a look.

.SLN file

The .sln file contains text-based information the environment uses to find and load the name-value parameters for the persisted data and the project VSPackages it reference

PDB is an abbreviation for Program Data Base. As the name suggests, it is a repository (persistent storage as databases) to maintain information required to run your program in debug mode. It contains many important relevant information required while you debug your code (in Visual Studio), for e.g. at what points you have inserted break points where you expect the debugger to break in Visual Studio.

.dll A DLL file, short for Dynamic Link Library, is a type of file that contains instructions that other programs can call upon to do certain things. This way, multiple programs can share the abilities programmed into a single file, and even do so simultaneously

The obj folder holds object, or intermediate, files, which are compiled binary files that haven't been linked yet. They're essentially fragments that will be combined to produce the final executable. The compiler generates one object file for each source file, and those files are placed into the obj folder.

The bin folder holds binary files, which are the actual executable code for your application or library.

Managed Unmanaged code

DataTypes:

Iteration Statements

  1. do
  2. for
  3. foreach
  4. in
  5. while

Boxing Unboxing

Implicit and Explicit Type Conversion

> Normal Datatypes + conversion in classes link

Value Types

The value types consist of two main categories:+

Structs fall into these categories:

--

--

Harshit Yadav

Software Developer | Azure Solution Architect Expert | Technical Writer | harshityadav.in