Jacques Gaudin Jacques Gaudin - 1 year ago 83
C# Question

What is a C# solution and how to use it?

I am new to C# (coming from Python and C) and when I start a new project in Monodevelop or Visual Studio, the project is put in a "solution" container.

I had a look at Microsoft description of what a solution is but I don't really understand the benefit of this and how I should use it.

The Microsoft documentation says:

A project is contained, in a logical sense and in the file system, within a solution, which may contain one or more projects, along with build information, Visual Studio window settings, and any miscellaneous files that aren't associated with any project. In a literal sense, the solution is a text file with its own unique format; it is generally not intended to be edited by hand.

Could someone explain what "solutions" are here for?

Answer Source

A solution is a workspace that combines multiple projects, which are usually related to each other. The construct is very useful in situations when some code needs to be shared among multiple projects.

For example, if you are developing a web site with a separate server-side component, you could segregate it into several related projects:

  • A project containing common interfaces, producing a DLL
  • A project containing database definition, producing an RDBMS deployment script
  • A project containing server-side API implementation, producing an executable
  • A web site project, producing an IIS deployment script

These four projects are connected to each other. Placing them into a single solution lets you access individual parts, while taking advantage of common indexing that Visual Studio does for you to simplify searches for usage and to help with refactoring.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download