I have 2 classes that have exact two functions. The difference between them is they modify the member variables of their own class.
class A
{
public hello;
public void methodA ()
{
// code to modify hello
}
}
class B
{
public hello;
public void methodB()
{
// code to modify hello
}
}
Method A and B do the exact same thing but to different hello (one in class A one in class B).
Is there any way I can avoid duplication here? I think probably delegate will be the answer, but I don’t know how. Please give me guidelines, I am a student and still learning. Thanks beforehand.
EDIT: The reason the classes have the same functionality but are separate classes, is because one is in a Windows application, and the other in a console application.
If the classes share the exact same functionality, then they should be combined into one class. If you have to share this class among different applications, you can put this class into a separate assembly, and reference the assembly from both your Windows and console applications.