🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Questions about C#

Started by
4 comments, last by ptietz 5 years, 1 month ago

Hello,

So I have been programming with C++ for 2.5 years now. I have been interested in checking out C# for fun. My question is pretty simple. Does C# use a form typically for their games? The simple game examples I have watched on YouTube reminds me A LOT of Visual Basic. 

Was this just an easy way to show you C#? Or using the form is a big part of C#? Or is it nothing more than using something like MFC and completely irrelevant to making games?

Thanks

Advertisement

C# can be used for a wide variety of things, not just Forms.  You can use it with Unity to make games.  You can use it with ASP.Net Core to make web pages or web services.  You can make command line tools.  You can port to various other operating systems (not just Windows). 

There are a lot more things you can do with it than I could even list.

It has the same sort of of variety you have with C++ (not exactly the same, but very flexible).

7 hours ago, RamblingBaba said:

Or is it nothing more than using something like MFC and completely irrelevant to making games?

MFC is obsolete and it is replaced by C# forms. The difficulty for using C# in games is that any library is first exposed by C++ and you need to build CLI layer to use it inside C# modules. C# as managed language runs over unmanaged C++ libraries as for OS resources (sockets for example), and has only basic types/operations included as isolated.

Forms, especially Winforms are obsoleted too and have been replaced by WPF. You can run your game in C# even if there are some libraries written in C++ you need like OpenGL for rendering, they could be included into your C# code via C++/CLI (not recommended) or the more flexible p/invoke layer using DLLImport Attribute and the function signature. The other way round is a lot harder to achieve because you need to provide a CLR in your C++ application to run C# in the same process but you could also run the C++ and C# in different processes and just communicate via IPC.

C# can also be transpiled into native code using either IL2CPP or from this GitHub project IL2CPU, an x86 assembler to run directly on the hardware without any OS arround it

Well, Visual Basic and C# are both Microsoft's domain. So that's why you might see similarities there. Personally, though, I think they're both very different. For me C++ looks different from most other languages. So that might also have lead to your impression.

I believe there is no such language that is inherently better suited for games than others. You could do a whole Game based on JavaScript. Sure, some engines use other languages than others. But you're not confined to a specific engine to realize your vision, are you?

The forms, you mentioned are part of Microsoft's .NET framework work and I believe they work with Basic just as well. Though, I'd rather not because MS has restructured their whole desktop thing with the new apps they have. Also, Unity, for example, handles forms in a totally different way.

This topic is closed to new replies.

Advertisement