Csharp To Executable Code

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

.NET Framework is a software framework developed by Microsoft.

It provides a
controlled programming environment where software can be developed, installed,
and executed mainly on Windows-based operating systems.

Core Components of .NET:

1. Common Language Runtime (CLR): It is the runtime environment that


manages and executes .NET programs. It provides memory management,
security, and exception handling.
2. .NET Class Library: A collection of reusable classes, interfaces, and value
types that can be used to develop applications.
3. Common Type System (CTS): It provides a common set of data types
ensuring that objects written in different .NET languages can interact with
each other.
4. Common Language Specification (CLS): A set of rules and specifications
that are adhered to by the languages under the .NET framework, ensuring
interoperability between them.
5. ASP.NET: A part of the .NET framework that is used for building dynamic web
applications and services.
6. Entity Framework: An Object-Relational Mapper (ORM) that enables .NET
developers to work with relational data using domain-specific objects.
7. LINQ: Language-Integrated Query, which allows developers to write queries
directly within the .NET programming languages.

.NET Core and .NET 5+:

.NET Core is a cross-platform, open-source successor to the .NET Framework,


intended to allow applications to run on different operating systems (Windows,
macOS, Linux).

.NET 5 is the next step forward, unifying the .NET platform. .NET 5+ builds on .NET
Core, aiming to bring a single .NET runtime and framework that can be used
everywhere, ensuring uniform runtime behaviors and developer experiences.

Languages:

.NET supports multiple programming languages, the most common being:

 C# (C Sharp): A modern, object-oriented programming language.


 VB.NET (Visual Basic.NET): An evolution of the Visual Basic language.
 F# (F Sharp): A functional-first programming language.

Development Tools:
 Visual Studio: A powerful IDE from Microsoft for developing .NET
applications.
 Visual Studio Code: A lightweight, open-source editor also from Microsoft,
suitable for .NET development with appropriate extensions.

Use Cases:

.NET is versatile and can be used for various types of applications such as:

 Web applications (via ASP.NET)


 Desktop applications (Windows Forms, WPF)
 Mobile applications (Xamarin)
 Cloud Services (Azure)
 Games (Unity with C#)
 IoT Applications
 AI and Machine Learning (ML.NET)

Deployment:

.NET applications can be deployed on various platforms, including Windows, Linux,


and macOS, especially with the advancements brought by .NET Core and later
versions. They can also be hosted on cloud platforms like Microsoft Azure, AWS, and
Google Cloud Platform.

.NET remains one of the predominant frameworks for building robust, scalable, and
maintainable software due to its extensive features, strong type-checking, just-in-
time compilation, and versatile libraries.

C# code to executable code

1. Source Code (C# Code):


This code is high-level, human-readable, and conforms to the syntax and semantics of the C#
language

2. Compilation:
The C# compiler ( csc.exe) compiles the source code into an intermediate form, known as
Common Intermediate Language (CIL) or Microsoft Intermediate Language (MSIL). Alongside
the CIL code, metadata describing the types, members, references, etc., in the code, is also
generated.

public class Program .method public hidebysig static void Main() cil
managed
{
{
public static void Main()
.entrypoint
{
.maxstack 3
int x = 10;
.locals init (
int y = 20;
[0] int32 x,
int sum = Add(x, y);
[1] int32 y,
System.Console.WriteLine(sum);
[2] int32 sum
}
)

public static int Add(int a, int b)


ldc.i4.s 10 // Load the constant value 10 onto
{ the stack.
return a + b; stloc.0 // Pop value from stack into local
} variable 0 (x).

3. Assembly:
The CIL code and metadata are packaged together into an assembly. The assembly usually
has a .dll (dynamic link library) or .exe (executable) extension, depending on whether it's a
library or an application. An assembly contains a manifest, which has information about the
assembly's version, culture, and other assembly metadata.
1. Execute: When you run the program, the .NET runtime loads the assembly
and starts executing the CIL code within the context of the Common
Language Runtime (CLR).

2. CLR Runtime: The CLR provides various services like memory management,
security, and exception handling. It hosts the Just-In-Time (JIT) Compiler which
converts the CIL code in the assembly to Native Machine Code specific to the
host computer architecture and operating system.

3. Native Machine Code: The JIT-compiled Native Machine Code is then


executed by the computer's processor.

You might also like