请帮我重构以下代码场景
我有两节课
class Example1
{
public string username {private get;set;}
public string password {private get;set;}
public obj[] callfunction(string value) {//code}
}
class Example2
{
public string UserName {private get;set;}
public string Password {private get;set;}
public List<ObjectDefinition> function1(string option)
{
Example1 obj = new Example1();
obj.username = this.UserName ;
obj.password = this.Password;
obj.callfunction(option)
//Other codes
}
public List<ObjectDefinition> function2(string option,string other,string other_more_params)
{
Example1 obj = new Example1();
obj.username = this.UserName ;
obj.password = this.Password;
obj.callfunction(other)
//Other codes
}
public List<ObjectDefinition> function3(string option)
{
Example1 obj = new Example1();
obj.username = this.UserName ;
obj.password = this.Password;
obj.callfunction(option)
//Other codes
}
//so on
}
所以我的问题是声明这个重复对象声明的最佳方式。