Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does C# require .NET

I'm new to C# (but not to programming) and I was wondering: do C# programs always require .NET, or are there ways to avoid dependencies and make the application independent?

like image 402
Paul Avatar asked Feb 16 '11 13:02

Paul


3 Answers

Yes C# always requires the .NET runtime.

If you are worried about other platforms there is Mono which will allow .NET applications to run on platforms other than Windows (i.e. Linux) using the Mono runtime.

C# code is compiled into CIL code which is a platform-independent instruction set, I quote from Wikipedia:

During compilation of .NET programming languages, the source code is translated into CIL code rather than platform or processor-specific object code. CIL is a CPU- and platform-independent instruction set that can be executed in any environment supporting the Common Language Infrastructure, such as the .NET runtime on Windows, or the cross-platform Mono runtime.

like image 136
BrokenGlass Avatar answered Sep 21 '22 06:09

BrokenGlass


A CLI runtime/interpreter is required, but it doesn't have to be .NET.

Currently there is one other CLI interpreter, MONO, for Linux.

like image 33
C. Ross Avatar answered Sep 24 '22 06:09

C. Ross


C# isn't compiled to native code, and therefore the computer can't read it. You need the .Net framework to convert the so called bytecode (the code that the C# compiler compiles to, CLI) can be converted by the Just In Time compiler of the .Net framework.

Mono is an alternative framework, and it can also run C#. It is supported on more platforms then then the .Net framework (that only supports Windows).

So yes, either the .Net framework or the Mono runtime is needed to run C# applications, new versions of Windows automatically install and update the .Net framework.

like image 38
Aidiakapi Avatar answered Sep 22 '22 06:09

Aidiakapi