0

Hi All,

When i excute this code at return people i get PeopleViewer.Person instead of there names.Can anyone tell me what i am doing wrong.

Thanks for the help.

namespace PeopleViewer
{
    class PeopleRepository
    {
        public Person[] GetPeople()
        {
            var people = new Person[]
            {
                new Person() {FirstName="JOhn",LastName="Sheridan",StartDate = DateTime.Parse("2/7/12"),Rating=2},
                new Person() {FirstName="Matt",LastName="Hugher",StartDate = DateTime.Parse("2/3/77"),Rating=2},
            };
            return people;
        }

    }
}


namespace PeopleViewer
{
    public class Person
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public DateTime StartDate { get; set; }
        public int Rating {get;set;}
    }
}
2
Contributors
1
Reply
17
Views
2 Years
Discussion Span
Last Post by ddanbe
1

Your GetPeople method returns an array of Person objects.
If you want to get, say a persons last name of the second person in the array, you use Person[1].LastName.

Edited by ddanbe: correction

Votes + Comments
This
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.