public class Part
{
public string PartName { get; set; }
public int PartId { get; set; }
}
public class Example
{
public static void Main()
{
// Create a list of parts.
List<Part> parts = new List<Part>();
// Add parts to the list.
parts.Add(new Part() { PartName = "crank arm", PartId = 1234 });
parts.Add(new Part() { PartName = "chain ring", PartId = 1334 });
parts.Add(new Part() { PartName = "regular seat", PartId = 1434 });
parts.Add(new Part() { PartName = "banana seat", PartId = 1444 });
parts.Add(new Part() { PartName = "cassette", PartId = 1534 });
parts.Add(new Part() { PartName = "shift lever", PartId = 1634 });
foreach (Part aPart in parts)
{
Console.WriteLine(aPart);
}
참조
https://learn.microsoft.com/ko-kr/dotnet/api/system.collections.generic.list-1?view=net-6.0