I have 2 different classes with a function with the same name:
class Class1
{
public static void Main()
{
Core.DoSomethingElse();
}
private static void DoSometing(string someParam)
{
Console.WriteLine("Hello from class 1");
}
}
class Class2
{
public static void Main()
{
Core.DoSomethingElse();
}
private static void DoSometing(string someParam)
{
Console.WriteLine("Hello from class 2");
}
}
And a Core class
What I want to do is to call these DoSomething() methods from the Core, since Class1 and Class2 will use Core:
Class Core
{
public static void DoSomethingElse(string someParam)
{
// Some code
/* This is where I want to call the method and
* **depending on which class is executing DoSomethingElse() method**
* call **its own DoSomething()** method
*/
DoSometing();
Console.WriteLine("Hello from Core");
//More code
}
}
Then I want to do something like this: If executing Class1, output:
Hello from class 1
Hello from Core
If executing Class2, output:
Hello from class 2
Hello from Core
I tried using interfaces but, since Class1 and Class2 must be static it didn't work, I also tried using virtual and abstract methods with inheritance, but then again it didn't work since methods must be static