Jump to content
  • Advertisement
Sign in to follow this  
essial

[.net] C# external file references?

This topic is 4094 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a way to reference external files in the same way as "include" in C++ and "uses" in pascal? Where I work, we currently use Delphi (visual pascal), and have Uses for a lot of common units that are used in multiple programs. I know that in C# you can create libraries and reference the DLLs, but is there a way to include them inside the same project without having to make it as its own external thing? I'd need to reference it as either just a file name, or as a relative file (such at "..\..\MyFile.cs"). Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Just include it in the build. If you are using Visual C#, just add the file to the project. Otherwise just make sure it builds with the source for the project and you can access it. The only other option is to build a DLL and reference that.

Share this post


Link to post
Share on other sites
Why?

C# doesn't require lexical visibility of symbols the way C++ does. That is, if in file Foo.cs you define type Foo, and in Bar.cs you define type Bar, Foo and Bar can "see" eachother and you can use them freely in either file. So long as both files are part of the same project.

Share this post


Link to post
Share on other sites
Ok, I understand that much, I've seen it done with the DX managed SDK tutorials. But how exactly do you go about doing it? We are using Visual Studio 2005 (team edition or something like that). I know when i click to add a reference it requires a dll or smiliar (yes, I know now that this isn't what i'm trying to do). How would I add a file to the project, and only specify a relative path? Do I click ...->Add existing item.. and type in the non-literal path and name? And can I simply type in a file name, and have a project-level search path specified?

Thanks for your quick responses!

Share this post


Link to post
Share on other sites
Note that hitting add will copy the existing file into your project.



If you don't want this, click the arrow to the right of the "Add" button and select "Add As Link", which will keep the original file in the same place.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!