repl.it
@kironroy/

list_of_birds

C#

No description

fork
loading
Files
  • main.cs
  • Birds.cs
  • main.exe
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Linq;


namespace LINQStuff
{
    class Program
    {

        static void Main()
        {

            var birds = new List<Bird>
            {
                new Bird { Name = "Cardinal", Color = "Red", Sightings = 3 },
                new Bird { Name = "Dove", Color = "White", Sightings = 2 } ,
                new Bird { Name = "Robin", Color = "Red", Sightings = 5 } ,
                new Bird { Name = "Blue Jay", Color = "Blue", Sightings = 1 } ,
            };

            var canary = new Bird { Name = "Canary", Color = "Yellow", Sightings = 0 };
            birds.Add(canary);


            foreach (Bird bird in birds)
            {

                Console.WriteLine();
                Console.WriteLine($" Bird Name: {bird.Name} \n " +
                    $"Bird Color: {bird.Color} \n " +
                    $"Bird Sightings: {bird.Sightings} " );
            }

          
            Console.ReadLine(); // this takes out the line "press any key to continue"

        }
    }
}