0

I know how to do it in C++ with #include, but I actually can't understand how make it with c# usings

So. I have project that work with some data files. I have my own "Serializer" class for it. And I also want make simple console tool to work with those data files. This tool depends on "Serializer" too. Both projects in one solution.

I try "Add existed item" but it only makes a copy.

Actually i didn't want made separate projects. But it looks one project == one entry point.

enter image description here

Cœur
  • 37,241
  • 25
  • 195
  • 267
Stepan Loginov
  • 1,667
  • 4
  • 22
  • 49

2 Answers2

2

If you want to access a file/class placed in one project from other project you can add its namespace in your calling project, if that's what you are asking.

For instance, If your Serializer class is placed in projectA, in order to use it you might be creating an object of it or may be you have static methods in that class, whatever the case may be, you can add the reference of projectA in projectB. You can do that by right clicking on References of projectB and clicking Add reference and add projectA's reference in projectB. This way you can create objects of Serializer or call its static methods from within projectB without making its copy.

zeppelin
  • 451
  • 1
  • 4
  • 24
2

You don't want to add an item, you want to add a project reference.

To do this, right click on "References", then "Add Reference".

enter image description here

Choose the project you want to add a reference to:

enter image description here

Then include the using statement:

enter image description here

In your case, you would want

using hello.Helpers;
Leigh Shepperson
  • 1,043
  • 5
  • 13
  • Looks logical, but didn't work. `using hello;` work nice (root namespace). `using hello.Helpers;` don't see `Serializer` – Stepan Loginov Oct 16 '15 at 22:18
  • do you see `Serializer` when you just add `using hello;`? – Leigh Shepperson Oct 16 '15 at 22:25
  • Hmm. I can write directly in code `hello.Algo.` to see this class (`using hello;` only). But I cant make it with Helpers folder. All other class/namespaces is Ok. – Stepan Loginov Oct 16 '15 at 22:34
  • 1
    @StepanLoginov Is your serializer class made public? Can you share the signature of your serializer class. The line of code where Serializer class is declared. Make sure Serializer class is declared as `public` – zeppelin Oct 16 '15 at 22:35
  • Yeap public is missed. public + rebuild solution is an answer – Stepan Loginov Oct 16 '15 at 22:44