Use another project's function in a solution

.net, c#

Solution

No it isn't. A function, or a method, is contained in a type, which is contained in an assembly. If you haven't access to this assembly, you can't use the method of this type, because you cannot either create an instance of the type -if the type isn't static- or use the type's name -if the type is static-.

Update

I say that's not possible in the context you cannot add a reference of one project to the other.

In order you avoid to write the same code twice, I would suggest you create another project, whose output would be a dll and there add the class or the classes that would be used by both projects A and B. In the class or classes, which you will define in the new project you can define the common methods you want and later use them from both project A and B. That should be a good approach, because later you could use this assembly to othet projects. So you will not have to write the same code from the start or make copy/past.

Problem

I have a solution with two projects. I cannot add a reference of A in B because it creates circular dependency. For avoiding redundant code, I would like to use a function in one of my projects in the other project. Is that possible?

Original source