Explore Visual Studio For Mac
Hello guys!
In this article, we’ll learn start to finish about Visual Studio for Mac tools and debugging and how to start with console projects. So first, read
my last article to know more about the installation process. When you are done with the installation, just go to your Mac Launchpad to show all applications or open Visual Studio from Application Finder.
Now, click on "New Project" option to find the project templates provided by Visual Studio.
I have selected "Console Project" in .NET category. Then, click "Next" to give names to the Project and Solution.
Give any name of your choice for this demo app. I set FirstCUIAppOnMac as Project name and DemoApp as my Solution name. You can see the solution preview also at the right side of this window. At last, you can change the location of the project source code.
Finally, press the "Create" button.
Now, if you go to that location where you have created your project, you will get your Solution (.sln) file and project file (.csproj).
Now, go back to Visual Studio and check what are the files and references we get in default template.
Just like other Visual Studio versions, we have the same folder structure in Visual Studio for Mac. A little difference here is that we only have one reference by default which is “System”. If you want more, then right click on References folder and find "Edit References" option.
Now, you’ll get a window where you have options to find your assembly from .NET Assembly or you can browse if you have any custom assembly.
At the right side of this window, you have a list of all existing assemblies in your project.
Now, enter any assembly name to search and select. Then, click OK.
After adding that assembly in your Solution, you can see that in your references.
If you want to use other main windows on Visual Studio, like Toolbox, Property Window, or many more, then just check the right side.
You also have a default Program.cs class that has a default Main() function that you can change according to your requirement.
After developing your app, you need to debug it. So, find the start option at the top left.
Now, for learning more about Visual Studio for Mac, we need to code more. So, let me add a new file.
Find the class file to code in C#.
I just add an Empty class named as Student.
I am writing some properties for checking the intelliSence. When you try to use them, it gives you intelligence suggestions, as shown in the below image.
After creating my class, it’ll look like below.
Now, I have created an object to use that code in my program.cs in Main () with some default values.
At last, after you are done with the code, just press "Start" button and it’ll start debugging.
For a proper RunTime in Mac, .NET apps require Mono framework for Mac. Thus, it’ll automatically start Mono.
Here is the output.
Thanks.