Can I program c# on a mac?

2019-04-04 07:54发布

问题:

I am just curious.I want to learn c# for unity. I am a dorm student, my personal computer is a macbook air and we have a pc computer room for public. I am just asking if I can use c# on a mac.

回答1:

Your first option is Microsoft Visual Studio for Mac which was released in 2017. If you're used to VS ide then I suggested you download this.

If not then you can have a look into MonoDevelop. You can download from here

MRE = Mono Runtime Environment

MDK = Mono Development Kit.

MDK = MRE + Extra tools, libraries, .NET PCL (Portable Class Library) profiles, etc.

If you have an application that you want to run that needs Mono you can install just the MRE.

If you are doing development, writing C# applications, whilst you can sometimes get away with just having the MRE installed, you may hit some missing features such as not having the .NET PCL profiles. So I would install the MDK if you are doing development. Reference



回答2:

Yes, it is. Microsoft has released Visual Studio Code 2017. It works on Windows, Mac OS, and Linux; It is quite nice development text-editor. It works similar to the full-version, available on Windows - with a few draw-backs, and it will allow to write programs, as well as run and test them right on your Mac.

Microsoft Docs offer a quick getting started tutorial and a Hello World program out-of-the-box with the Visual Studio Code.

You will need to install a few dependencies, however. Which may sound kinda of obvious:

  1. Visual Studio Code
  2. .Net Core SDK
  3. C# extension from the marketplace.

I had good luck getting started and Visual Studio got all of the dependencies for me; so I simply went into the program, opened the integrated terminal (View > Integrated Terminal) and ran the command dotnet new console, and boom, a few seconds later I had a Hello World program, written in C#, running on my MacBook Pro.



回答3:

There is now a Visual Studio for Mac available as a free community version as well as professional and enterprise versions by subscription.

JetBrains also has an IDE for C#, called Rider, that runs on the Mac. If you use IntelliJ or any of their other products you might like it - it feels better to me than MonoDevelop or Visual Studio for Mac. It is a commercial product but JetBrains offers very generous license terms (as in free) for students and open source projects. They also have a substantial discount for startups.



回答4:

It is entirely possible, if you install a version of Windows using Bootcamp you can switch between the two at start up and have the full functionality of both by installing Visual Studio on the Windows partition. Alternatively, you could use VMware such as Virtual Box and use Windows within your Mac OS.



回答5:

Note that while everyone mentions Mono and Xamarin, which you should absolutely look into for C# development, Unity works on Mac directly, specifically Mac OSX 10.6+

while both use the C# language, some of the paradigms espoused by Unity are a little different from standard C# development. I personally recommend learning both.

ADDENDUM: Note that MS has recently announced that they'll be moving the standard .NET implementation cross-platform, and are doing so with the help of the Mono team, so while there's currently a confusing dual set of tools, it'll be shifting away from this in the future



回答6:

It is possible, but you won't be able to use Microsoft's tools, you'll need to use a third-party program like Xamarin Studio (MonoDevelop).

Edit

at the time of this answer there wasn't a Microsoft tool/IDE that could be used for developing .net / C# programs on a Mac. Now there are two:

  1. Visual Studio Code
  2. Visual Studio for Mac