fork download
  1. using static System.Console;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Program {
  6. public static void Main() {
  7. var lista = CriarCompras(10);
  8. lista[0].Item = 1;
  9. foreach (var item in lista) WriteLine(item.Item);
  10. }
  11. private static List<Compra> CriarCompras(int numComprasParaGerar) => new int[numComprasParaGerar].Select(i => new Compra()).ToList();
  12. }
  13.  
  14. public class Compra {
  15. public int Item = 0;
  16. }
  17.  
  18. //https://pt.stackoverflow.com/a/89648/101
Success #stdin #stdout 0.02s 17196KB
stdin
Standard input is empty
stdout
1
0
0
0
0
0
0
0
0
0