Hello! I have question connected with interfaces and abstract classes. I'll give to you simple example, that could explain what I want to do. So, Lets start.
public interface A
{
string param1 { set; get;}
string param1 { set; get;}
A CreateObject(string p1,string p2);
}
public class MyClass1 : A
{
public string param1 { set; get; }
public string param2 { set; get; }
public A CreateObject(string p1,string p2)
{
var obj = new MyClass1();
obj.param1 = p1;
obj.param2 = p2;
return obj;
}
}
public class MyClass2 : A
{
public string param1 { set; get; }
public string param2 { set; get; }
public A CreateObject(string p1,string p2)
{
var obj = new MyClass2();
obj.param1 = p1;
obj.param2 = p2;
return obj;
}
}
// I have little problem with this function
public List<A> GetNodes(int count)
{
var lst_Objects = new List<a>();
for(int i=0; i<count; i++)
{
string Param1 = GetParam1();
string Param2 = GetParam2();
lst_Objects.Add(new A.CreateObject(Param1,Param2); // but it defenitly doesn't work(wrong way)
}
return lst_Objects;
}
I have problems with GetNodes function. Tip: MyClass1 and MyClass2 is Entity objects, and because of this reason I can not create abstract class, and use some generic to resolve this problem.
I will grateful for your ideas