csharp
1using System;
2using System.IO;
3using System.Text;
4using System.Linq;
5using System.Collections.Generic;
6
7public class Program
8{
9 public static void Main()
10 {
11 一行ならできる();
12 Console.WriteLine();
13 列方向の出力はできる();
14 Console.WriteLine();
15 質問したかったと考えられること();
16 }
17 public static void 一行ならできる()
18 {
19 var (j, diameter, height, person) = Sample().First();
20 using var sw = new StreamWriter(Console.OpenStandardOutput(), Encoding.UTF8);
21 sw.WriteLine(j);
22 sw.WriteLine(diameter);
23 sw.WriteLine(height);
24 sw.WriteLine(person);
25 }
26 public static void 列方向の出力はできる()
27 {
28 using var sw = new StreamWriter(Console.OpenStandardOutput(), Encoding.UTF8);
29 foreach(var (j, diameter, height, person) in Sample()) {
30 sw.WriteLine(j+","+diameter + ","+height + ","+person);
31 }
32 }
33 public static void 質問したかったと考えられること()
34 {
35 var js = new List<string>();
36 var diameters = new List<double>();
37 var heights = new List<int>();
38 var persons = new List<string>();
39 foreach(var (j, diameter, height, person) in Sample()) {
40 js.Add(j);
41 diameters.Add(diameter);
42 heights.Add(height);
43 persons.Add(person);
44 }
45 using var sw = new StreamWriter(Console.OpenStandardOutput(), Encoding.UTF8);
46 sw.WriteLine(string.Join(",",js));
47 sw.WriteLine(string.Join(",",diameters));
48 sw.WriteLine(string.Join(",",heights));
49 sw.WriteLine(string.Join(",",persons));
50 }
51 public static IEnumerable<(string, double, int, string)> Sample() {
52 yield return ("ID01", 3.14, 15, "Adam");
53 yield return ("ID02", 6.28, 30, "Bob");
54 yield return ("ID03", 9.42, 45, "Charlie");
55 yield return ("ID04", 12.56, 60, "Dannie");
56 }
57}