Skip to main content
gamedev.net
🔒 Locked

C# portability

Started by jim bob Aug 28, 2003 at 11:19 PM 6 replies 1.5k views
Original Post
jim bob
jim bob
I am using Visual C# .Net Standard Edition. I essentially have one question regarding C#: How portable is C#? a) ANY application I write can ONLY run on a machine with the .Net framework installed? b) Is there such a thing as UNmanaged C# code, not using the .Net libraries, making it similar to old school C or C++ code in VC++ 6 or less? c) Can C# code run on a Linux machine? A Mac? Etc... d) What is Mono, and how is it compared to VC# and/or the .Net framework, in terms of portability? I am aware these questions are probably asinine, but I would appreciate help regardless. Thank you all!
I am not worthy of a sig! ;)
VizOne
VizOne
a + b) Theoretical, C# is just a language (keywords, syntax etc.), so if you like to, you *could* write a compiler that compiles it to anything you want. However, all compilers available compile for the .NET framework. This is what C# was intentionally created for. And any program compiled for the .NET Framework needs it to run.
c + d) Theoretical, .NET programs can run under any OS that runs a port of the CLR. Mono is such a port for unix/linux, but IIRC ports for other OS's are being developed right now. Sadly mono currently lacks the support for Forms.

Regards,

VizOne

[edited by - VizOne on August 29, 2003 4:10:10 AM]
PaulCunningham
PaulCunningham
A) Yes - it only need the redistributable installed (not the full SDK)

B) I''m not sure there is such a thing as ''unmanaged C#'' but you can use unmanaged code from C# via the System.Interop namespace.

C / D) www.go-mono.com

Cheers,
Paul Cunningham
Cheers,Paul CunninghamPumpkin Games
cody
cody
i have made a small network game in c# and tried to run the server on linux with mono.
it didnt work.
it throws exceptions because some arrays are accessed with indices that are bigger than the array. i dont know why this happens, the windows server works allright.
so i think .net is not really cross-platform yet.
(or i did something wrong...)
PuterPaul
PuterPaul
In response to part b, you can indeed use the "unsafe" keyword to go old skool. Be warned though future systems may not run any code with instances of the "unsafe" code.
jperalta
jperalta
Unsafe allows you to access pointers to certain objects, but those objects must be unmanaged and it does all sorts of wacky stuff. suffice to say that in all the C# I write (and that is the main language I use now ''cause I happen to be good at it and I like it) I''ve used unsafe only once or twice and that was only a temporary fix until I could find some better way to write it. Writing unmanaged C# is the most obnoxious feat attemptable something akin to attempt to write a useful program in Pascal.
tortoise
tortoise
quote:
Original post by jperalta
Unsafe allows you to access pointers to certain objects, but those objects must be unmanaged and it does all sorts of wacky stuff.


I thought ''fixed'' was what enabled pointers to managed objects. A managed object made fixed is not moved around by the GC. But that''s just what I read, I haven''t done much C# yet. What''s the real story?
thona
thona
You are right, tortoise, and jperalta should read the documentation before saying garbage which people might tae seriously.

Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)
RegardsThomas TomiczekTHONA Consulting Ltd.(Microsoft MVP C#/.NET)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.