A
AA
I have this simple class
public class Person
{
public Person(){}
public String Name = String.Empty;
public String LastName = String.Empty;
}
and this procedure that has one input parameter of type Object
public void FillPerson(ref Object inObj)
{
//do something with the object inObj
}
well, my problem is when I create a new instance of the class Person and
pass it to the procedure, something like this...
private void NewPerson()
{
Person PersonOne = new Person();
FillPerson(ref PersonOne); // In this line appear this error when I
compile...
//"Argument '1': cannot convert from
'ref Company.Person' to 'ref object'
// The best overloaded method match
for 'Company.FillPerson(ref object)' has some invalid arguments
}
but..... if i create a new object instance of type 'object' everything is
compiled ok.
private void NewPerson()
{
Person PersonOne = new Person();
Object PersonOneObj = PersonOne
FillPerson(ref PersonOneObj); // This work perfectly.
}
So, why I can pass my object Person as Object?
Thanks a lot
I really will apreciate your answer
AA
public class Person
{
public Person(){}
public String Name = String.Empty;
public String LastName = String.Empty;
}
and this procedure that has one input parameter of type Object
public void FillPerson(ref Object inObj)
{
//do something with the object inObj
}
well, my problem is when I create a new instance of the class Person and
pass it to the procedure, something like this...
private void NewPerson()
{
Person PersonOne = new Person();
FillPerson(ref PersonOne); // In this line appear this error when I
compile...
//"Argument '1': cannot convert from
'ref Company.Person' to 'ref object'
// The best overloaded method match
for 'Company.FillPerson(ref object)' has some invalid arguments
}
but..... if i create a new object instance of type 'object' everything is
compiled ok.
private void NewPerson()
{
Person PersonOne = new Person();
Object PersonOneObj = PersonOne
FillPerson(ref PersonOneObj); // This work perfectly.
}
So, why I can pass my object Person as Object?
Thanks a lot
I really will apreciate your answer
AA