Create a list of 3 Orders c#
using System;
using System.Collections.Generic;
namespace ConsoleApp5
{
class Program
{
static void Main(string[] args)
{
var obj = new Class1();
obj.Test();
}
}
public class Class1
{
public void Test()
{
var myList = new List<MyObject>();
myList.Add(new MyObject { Id = 1, Name = "ZZZ" });
myList.Add(new MyObject { Id = 2, Name = "NNN" });
myList.Add(new MyObject { Id = 3, Name = "PPP" });
myList.Add(new MyObject { Id = 4, Name = "AAA" });
foreach (var obj in myList)
{
Console.WriteLine($"{obj.Name} -> {obj.Id}");
}
}
public class MyObject
{
public int Id { get; set; }
public string Name { get; set; }
}
}
}