简体   繁体   中英

How to share constants between projects?

I'm working on a C# console app that dumps data into a database, and an aspx / aspx.cs front end that reads that database to display the data.

Is there a neat way I can share the database table information between the two projects? Table name, column names etc?

1) Create a project for the Data Access Layer

2) Include the project in both the other 2 projects

3) Use the classes you made

You can hold those values in files which are set as embedded resources , and then include the same files in more than one project. The Embedded Resource content type works for any file, but there is additional framework support for.resources files that make them easier to access at runtime.

You could also create another class library project just to hold those values, and include that project as a dependency of several projects. However creating an assembly just to hold a few constant values feels like a misuse to me.

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