fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace TeraTail35197
  5. {
  6. class Program
  7. {
  8. class Data
  9. {
  10. public List<string> names;
  11. public List<int> prices;
  12. }
  13.  
  14. static void Main(string[] args)
  15. {
  16. var data = new List<Data>()
  17. {
  18. new Data()
  19. {
  20. names = new List<string> { "Apple", "Orange", "Grape" },
  21. prices = new List<int> { 200, 300, 150 }
  22. },
  23. new Data()
  24. {
  25. names = new List<string> { "Carrot", "Tomato", "Cucumber" },
  26. prices = new List<int> { 100, 200, 300 }
  27. },
  28. };
  29.  
  30. foreach (var x in data)
  31. {
  32. foreach(var name in x.names)
  33. {
  34. Console.WriteLine($"name: { name }");
  35. }
  36.  
  37. foreach (var price in x.prices)
  38. {
  39. Console.WriteLine($"price: { price }");
  40. }
  41. }
  42. }
  43. }
  44. }
  45.  
Success #stdin #stdout 0.05s 23992KB
stdin
Standard input is empty
stdout
name: Apple
name: Orange
name: Grape
price: 200
price: 300
price: 150
name: Carrot
name: Tomato
name: Cucumber
price: 100
price: 200
price: 300