Answers for "what are list and how we use it c#"

C#
0

lists in c#

public class Part : IEquatable<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 });
      //
      foreach (Part aPart in parts)
        Console.WriteLine(aPart);
    }
}
Posted by: Guest on June-14-2021

Code answers related to "what are list and how we use it c#"

C# Answers by Framework

Browse Popular Code Answers by Language