简体   繁体   中英

How can I save a C# project in VisualStudio into a single .cs file instead of a whole project folder?

I have been practicing programming this way, but for my exam I will need to hand in a single script file, and I don't know how to do that. When I try to create a single file it's totally empty, is there a way of having all that starting structure but still saving only into a single.cs script?

A "project" ( .csproj file plus one or more .cs files): no. (Unless you mean some archive format like Zip.)

But there is no limit on how many namespaces, classes, etc. can be in one source file. While good practice is to put one top level type in one file (member types and partial classes can modify this) this is not required by the compiler.

NB. the use of the term "script" in your question needs better definition here. Typically one refers to "source" files. Maybe your instructor means "project write up" as a single document, with the expectation you'll include the source in it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM