Running a c# subroutine using Visual Studio code

zachvaldez
zachvaldez used Ask the Experts™
on
I'm not successfully running my subroutine in visual studio code. How can I run this is Visual Studio code?
using System;

namespace SelectSort
{
    class Program
    {
   static void Main(long[] list, int min, int max) {
  int ic;

    long best_value;
    int best_j;
    for (ic = min; ic <= max - 1; ic++)
    {
        best_value = list[ic];
        best_j = ic;
        for (var ji = ic + 1; ji <= max; ji++)
        {
            if (list[ji] < best_value)
            {
                best_value = list[ji];
                best_j = ji;
            }
        }
        list[best_j] = list[ic];
        list[ic] = best_value;
    }

        }
    }
}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior .Net Consultant
Top Expert 2016
Commented:
VS Code is an editor. It won't run C# code.

Author

Commented:
ok, I created a new project. How can I call the subroutine using a button click?
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
Are you using Visual Studio Code (https://code.visualstudio.com/) or the full IDE of Visual Studio?

If you are using the full VS, what type of project have you created? Console, Windows Forms, WPF, ASP.Net, ...
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
I could not make this work using visual studio code with console.
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
A console application cannot show a button. It does not have a UI.

And can you confirm that you really want to use the VSCode product (link above) for which I already said that you will not be able to run C# code.
NorieAnalyst Assistant

Commented:
You can apparently use VS Code to run C#, see here.

Note I've tried this before but not with much luck - I gave up after a while, though I was probably doing something wrong.

It's probably easier to use Visual Studio, here's a link for the Community Edition.
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
I knew you can add some plug in but it is not the purpose of VSCode especially that he is asking for a button click (which comes from a UI that is definitely not supported by VSCode). But I never had the answer to my question if was really using VSCode or a full VS IDE.
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
Hi zachvaldez,

VSCode works in a bid different fashion. Did you follow these setps described at: https://docs.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio-code

I could debug your code following those steps, let me know if you run into any issues.

Regards,
Chinmay.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial