Itay Almog
Itay Almog

Reputation: 9

Merge C# source files into one

I am participating in a programming competition, The competition uses a website where you just upload your source file and than it tests it, The problem is that I have multiple C# Source files. Is there a software or website which allows me to merge multiple C# source files into one?

I would happily ZIP the files but the website does not support uploading ZIP files with the sources inside...

Upvotes: 1

Views: 1096

Answers (2)

Deneas
Deneas

Reputation: 36

I ran into the same issue and found that a solution as proposed by i486 is actually doable.

You can merge all cs files into one, but you have to take care of usings.

To put it simply all code needs to be inside a namespace. Yes, even the usings, especially those, else you're going to have compiler errors.

To make that even easier you could even StyleCop with the rule "SA1200: Using Directives Must Be Placed Correctly" to enforce this.

Also to clarify, you don't need a namespace per file, it is perfectly acceptable to have the same namespace multiple times in a file.

Upvotes: 2

i486
i486

Reputation: 6563

From Command Prompt, go to folder with C# files and run this:

for %a in (*.cs) do type %a >>all.txt

Then rename all.txt to all.cs

Upvotes: 0

Related Questions