I want to call a method where two parametres are objects (one retrieve Person, one added Person). Then store in array of Person objects and then I can work with both object separatelly.
In method:
I do create object Person and store data in it from retrieve data from database where firstName is “Mediterranean”.
And add other row(Person features) and do want to pass it back as well.
But doesn’t return objects and straight fail.
Can somebody help me please?
I have something like this:
public Person [] retrievePerson(Person somePerson, Person addRowPerson)
{
.......
findedPerson = new Person(title, firstName, secondName, city, nationality, letter);
myTableCreatedPerson = new Person(title, firstName, secondName, city, nationality, letter);
return retrievePerson(findedPerson, myTableCreatedPerson);
}
//and calling function in different class like that
public void retrievePersonTest() //Create Person in DB directly then Retrieve Person and compare retrieve features with create features then directly delete him from DB
{
Person expected = null;
Person actual = null;
Person addRowPerson = null;
Person [] twoPersonArray;
DBConnect target = new DBConnect();
try //retrieve Person
{
twoPersonArray = target.retrievePerson(expected, addRowPerson); //do not return
twoPersonArray = (Func<Person, Person>)target.retrievePerson(expected, addRowPerson).CreateDelegate(typeof(Func<Person, Person>)); //do not return either
}
}
You created an endless recursion, because at the end of
retrievePersonyou are calling it again.You need to change the return statement of
retrievePersonto this: