'Using multiple projects in C# with Visual Studio 2019

I have made a checkers game using Console, written in C#.

I was thinking about seperating the engine of the game from the UI.

So I made a namespace named "Logic", and a namespace named "User-Interface". Both in the same solution.

My vision is that User-Interface namespace would hold only printing functions. But, to hold the printing functions I made, I need an access to Logic's classes.

So I changed "Logic" output type to Class Library.

But, inside Logic namespace, I have the running engine. I have info inside Logic namespace, that I want to output to "User-Interface" so that the console would print properly.

So I'm in a position that Logic wants to reference User-Interface, and User-Interface wants to reference Logic, which cause me an infinite reference loop.

enter image description here

Let's take the next function for example: enter image description here

PrintBoard fuction is sitting inside UI.Program.cs.
To work, it needs to reference Logic and get his Cell class.
But I want to run this function inside Engine class.
So confusingly I need UI to reference Logic in order to get Cell, and I need Logic to reference UI in order to active the function inside Engine class.

What am I supposed to do in this case? Perhaps delete namespace UI, and run it as a class inside Logic? I'm totally clueless.

Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source