Using Visual Studio, no. The best way is to keep the source code in a safe place. Depending on the situation this could mean places like:
- safe location in the network protected by proper folder privileges
- external mass media (hard drive, usb) which isn't accessible to others
And if you need, you can password protect the files for example using a zip. When working with the files uncompress them to proper place, make the modifications and update the zip file (or create a new one).
However, if you distribute the application, remember that a managed application can be translated back to source with several tools. One way to make the translation hard is to use
obfuscation[
^]. In .Net one tool you can use is
Dotfuscator[
^]