Print out a list

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • larslichon
    New Member
    • Apr 2010
    • 2

    Print out a list

    First off I have 3 classes, the first is the one with my main in, in here I make variables of the type that is the first class which I have called "Group". so I make groupA and groupB.
    Then in my group class I make a list of the last class that I have called names.
    In this class I have the variables string name and int age.

    so I add a person to groupA and groupB and wanna print out every person on each list. how do I do this?
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Bytes has a policy regarding assisting students with their homework.

    The short version is that the volunteers here can't help you with schoolwork.
    A) We don't know what material you have and have not learned in class.
    B) We don't know the guidelines you must follow.
    C) In the long run giving you the answers actually short changes your education.

    Hint 1: Try hitting Google with terms of your programming language and primary terms of what you want to do. For example "C# custom events" or "VB datagrid Excel". I've found this to be a very effective tool.
    Hint 2: Your text book
    Hint 3: Your instructor
    Hint 4: Posting guidelines regarding homework assignments.

    Comment

    • jkmyoung
      Recognized Expert Top Contributor
      • Mar 2006
      • 2057

      #3
      foreach loop? Not enough code provided.
      Code:
      foreach (Person p in names){
        Console.Write(p.name);
      }

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Overwrite the ToString method and do as jkmyoung has suggested....

        Comment

        Working...