3

I have trouble executing code that I have written in notepad++. As from what I have researched online, I should edit path in system variable to this C:\Windows\Microsoft.NET\Framework64\v4.0.30319. I have already changed it and it's still not working. After I type in test.cs, a windows form will pop up stating that windows can't open this file. Here is an image of my command line:

CMD Picture

Here is also the small code that I have written:

using System;

public class Test
{
    static void Main()
    {
        Console.WriteLine("***");
    }
}
6
  • Have a look at the .NET Tutorial Commented Sep 13, 2016 at 5:09
  • This isn't about compiling C# code. The compilation succeeded. This is about running the result. And you're not trying to do that using Notepad++ (nor should you). So out of "How to compile c# code using notepad++?", only the "How to" is relevant to this question. Commented Sep 13, 2016 at 5:10
  • Why do you want to do this? Or is this just an academic appraoch? Commented Sep 13, 2016 at 5:10
  • 1
    I guess you need to just enter test.exe. test.cs is your source file and test.exe is the executable file. Commented Sep 13, 2016 at 5:14
  • 1
    Honestly, why are you writing code in Notepad++ when you can get Visual Studio Community Edition for free? Commented Sep 13, 2016 at 5:22

2 Answers 2

10

After compiling your c# file, execute it by just typing the name in your command prompt. Don't use the extension again. Just type

test

after compiling successfully in your cmd prompt, and you'll be fine. You can also use

test.exe

to run it instead of just test.

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

2 Comments

Your and mine responses are same except formatting difference. You get 3 votes and also marked as answer and I get only one vote. I envy you :)
Thumbs up! Cheers :)
5

As I can see from the image, don't type test.cs. Instead type test and it will execute. test.cs is a c# prograram file and it can be opened in visual studio or notepad or can be compiled but can't be executed. It can be executed only after compilation. Compilation will give test.exe as an output and to run test.exe you can mention either test.exe or just test.

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.