This project is read-only.

Returing .net object

Oct 11, 2013 at 7:13 AM
Hi,

I have .net class say person
namespace Jam{

public class Person{
public string name;
public string telephone;
}

public class PersonDB
{
public static Person GetRandomPerson()
{
   Person t = new Person();
   t.name = "test1"; t.telephone = "00500";
   return t;
}
}

}

Inside my Javascript when I call:

var person1 = PersonDB.GetRandomPerson();

Now person1 is a type of object.
person1.toString() will return "Jam.Person"

But when I access person1.name or person1.telephone it will return undefined

Thanks
Jun 14, 2014 at 6:45 AM
Set your function "GetRandomPerson" to not static and when u calling "person1.toString();" you calling the object what you returned in your class "public Person GetRandomPerson()".
class Person is not a script but an object, try in your script "person1.name" or another variable from Person object.