以下是班级列表。这些类有一个共同的方法,其目标在类中是相同的。我想通过将此方法移动到第四类来删除 CommonMethod() 的重复,并从剩余的其他类中调用它
Class First
{
string ClassField
method FirstClassMethodOne()
{
CommonMethod()
}
method CommonMethod()
{
classField = 1
}
}
Class Second
{
method SecondClassMethodOne()
{
CommonMethod()
}
method CommonMethod()
{
Fifth.classField = 1
}
}
Class Third
{
method ThirdClassMethodOne()
{
CommonMethod()
}
method CommonMethod(string a, string b)
{
stirng ClassField
classField = 1
}
}
Class Fourth
{
string FourtClassField
method FourtClassMethodOne()
{
}
}