Link to home
Start Free TrialLog in
Avatar of zachvaldez
zachvaldezFlag for United States of America

asked on

Running a c# subroutine using Visual Studio code

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

ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zachvaldez

ASKER

ok, I created a new project. How can I call the subroutine using a button click?
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, ...
I could not make this work using visual studio code with console.
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.
Avatar of Norie
Norie

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.
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.
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.