Avatar of karelog
karelog
Flag for Chile

asked on 

C#: Object Oriented issue

Hello everyone!

I have this basic class:
 
Public class Person{
  private int age;
  private string name;

  public Person(){
    this.age = 0;
    this.name = "";
  }
  
  public int Age { get{ return this.age; } set { this.age = value; } }
  public string Name { get{ return this.name; } set { this.name= value; } }

}

Open in new window


I need to get a list of persons. So I want to make something that result in a code like this:
 
Person p = new Person();
firstPersonName = p.listPersons[0].name;
firstPersonAge = p.listPersons[0].age;

secondPersonName = p.listPersons[1].name;
secondPersonAge = p.listPersons[1].age;

Open in new window


could someone guide me into how to achieve this?

thanks
C#.NET ProgrammingSystem Programming

Avatar of undefined
Last Comment
karelog

8/22/2022 - Mon