1. Course
  2. Generic collections
  3. Queue of objects

Queue of objects


Last updated: 8/23/2020 Difficulty: Intermediate

Create a C# program that uses a Queue to store a list of people. First prepare a class called Person.cs with two properties (name and age) and a ToString() method to print the result.

Then define a Queue and request the information (name and age) of three people from the user, you will have to store the information in the queue. Remember that you can find the Queue object in the System.Collections namespace of the .NET Framework.

To end the program, print the data of the people walking the queue.

Input

  1. Juan
  2. 26
  3. Sara
  4. 31
  5. Carlos
  6. 23

Output

  1. Juan - 26
  2. Sara - 31
  3. Carlos - 23

Solution

Generic collections

3 / 5

Android App


Practice C# anywhere with the free app for Android devices.

Android App

Exercises C# by difficulty


Learn C# at your own pace, the exercises are ordered by difficulty.

Make a donation


Your donations support our work and contribute to the maintenance of the app.

Advertising


CookieOwn and third party cookies to improve our services. If you go on surfing, we will consider you accepting its use.