I have two console applications, Query and Update, which have some features. I wanted the two classes to inherit from a common base class, but the problem is that for a console application I have to have a function static Main. I currently have the following:
namespace Utils
{
public class ConsoleBase
{
protected const int ERROR_EXIT_CODE = 1;
protected static void printWarning(string msg) {...}
public ConsoleBase(IEnumerable<string> args) { ... }
...
namespace Update
{
class Update : ConsoleBase
{
private static ConsoleBase _consoleBase;
public static void Main(string[] args) { ... }
...
namespace Query
{
class Query : ConsoleBase
{
private static ConsoleBase _consoleBase;
public static void Main(string[] args) { ... }
...
It seems to me that the design problem for me is both inherited from ConsoleBaseand has an instance of it as a variable staticin each derived class. The reason I am doing this is as follows:
- I can have methods
protected staticdefined in ConsoleBasethat are available to other methods staticin derived classes. ConsoleBase, , public ConsoleBase.
, / ConsoleBase, .
_consoleBase.UseDebugMode()
, ConsoleBase,
printWarning(CONST_MSG_IN_BASE_CLASS);
? , ?