Ricky Wang

Hi, folks

I an new to C#, and I got a simple question:

How to compile and run a single .cs file in a solution

Thanks.

Ricky.




Re: Visual C# General How to compile and run a single .cs file

Matthew Watson

If the project consists of just a single .CS file, selecting Debug|Start Without Debugging will do that.

If your project consists of more that one .CS file, you can only compile and run the the entire project.





Re: Visual C# General How to compile and run a single .cs file

Saurabh Surana

If you don't wanna create project then for running sing cs file
you can use csc command....
Go to .net command prompt and type command
prompt:\> csc /

you will see all its options.









Re: Visual C# General How to compile and run a single .cs file

Ricky Wang

So one project can contain only one .cs file with main() method

Regards,

Ricky.






Re: Visual C# General How to compile and run a single .cs file

Matthew Watson

One Project can indeed only contain one Main() method (although you can actually pick any of the static methods in your code that has the right signature, but you can only pick one at once).

A Solution (.sln file) can contain many Project (.csproj) files though.




Re: Visual C# General How to compile and run a single .cs file

Ricky Wang

Thanks Matthew.

Ricky