using System;
using System.Collections.Generic;
public class GenericCollection
{
public class KpopGroup
{
public KpopGroup(string name, string comment)
{
_name = name;
_comment = comment;
}
private string _name = "";
private string _comment = "";
public string Name
{
get { return _name; }
set { _name = value; }
}
public string Comment
{
get { return _comment; }
set { _comment = value; }
}
} // class KpopGroup
public static void Main()
{
// Create a new LinkedList object.
LinkedList<KpopGroup> groupList = new LinkedList<KpopGroup>();
// Create KpopGroup objects to add to the linked list.
KpopGroup g1 = new KpopGroup("BLACKPINK", "The most popular KPop female group right now. Consists of 4 members.");
KpopGroup g2 = new KpopGroup("Kiss of Life", "Sexy vibe with amazing style. Consists of 4 members.");
KpopGroup g3 = new KpopGroup("Stray Kids", "Write and produce their own songs. Mind-blowing music videos and dance choreography. Consists of 8 members.");
KpopGroup g4 = new KpopGroup("BABYMONSTER", "Younger female group with monster-level talents. Consists of 7 members.");
KpopGroup g5 = new KpopGroup("TREASURE", "Immensely talented male group that needs more promotion from their company. Consists of 10 members.");
// Add the items to the linked list
groupList.AddFirst(g1); // BLACKPINK
groupList.AddFirst(g2); // Kiss of Life before BLACKPINK
groupList.AddBefore(groupList.Find(g1), g3); // Stray Kids before BLACKPINK
groupList.AddAfter(groupList.Find(g1), g4); // BABYMONSTER after BLACKPINK
groupList.AddLast(g5); // TREASURE at the end
Console.WriteLine("\nMy Favorite KPop Groups and Their Comments:\n");
// Display all items
foreach (KpopGroup grp in groupList)
{
Console.WriteLine(grp.Name + " : " + grp.Comment);
}
Console.WriteLine("\nDisplaying the second group in the ranking:\n");
Console.WriteLine("groupList.First.Next.Value.Name == " +
groupList.First.Next.Value.Name);
Console.WriteLine("\nDisplaying the next-to-last group in the ranking:\n");
Console.WriteLine("groupList.Last.Previous.Value.Name == " +
groupList.Last.Previous.Value.Name);
}
}