4

I wanted to test something using a console app and some command line arguments. I know of the run options in Visual Studio 2017 for Windows where you can specify the command line arguments, but the same settings in Visual Studio for Mac does not seem to work. I have provided a few command line arguments in the run configuration for the default configuration in the arguments entry, but upon debugging, the args[] is empty. Is this a bug or am I missing something?

TIA, John.

1

2 Answers 2

2

Rebuild your project for command line arguments supplied in:

Project Options > Configurations > [Configuration name] > Arguments to be passed into your Main successfully.

Sign up to request clarification or add additional context in comments.

1 Comment

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker.
2

I know this is an old post, but I think that it would be good to provide an answer for those looking to use the terminal, I did write about this after seeing there were no answers in an even older post.

When installing Visual Studio:Community Edition on MacOS you are given a suite of tools. Including csc and mono.

So to run a C# console program like the one below you will need to use both tools:

using System;

namespace helloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            string name = args[0];
            Console.WriteLine("Hello {0}", name);
        }
    }
}

Then compile the C# project by running csc:

$ csc Program.cs

If there are no errors csc will then create an executable file .exe, use mono to run the executable and pass the arguments:

$ mono Program.exe Bob
Hello Bob

With these two tools you can compile, and execute the C# program.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.