回答編集履歴
1
修正
test
CHANGED
@@ -5,3 +5,99 @@
|
|
5
5
|
data4とdata5のintをやめてList<int>にする。
|
6
6
|
|
7
7
|
という方法を思いつきました。
|
8
|
+
|
9
|
+
```C#
|
10
|
+
|
11
|
+
using System;
|
12
|
+
|
13
|
+
using System.Collections.Generic;
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
namespace listtest3
|
18
|
+
|
19
|
+
{
|
20
|
+
|
21
|
+
class Program
|
22
|
+
|
23
|
+
{
|
24
|
+
|
25
|
+
public class dataModel
|
26
|
+
|
27
|
+
{
|
28
|
+
|
29
|
+
public string data1 { get; set; }
|
30
|
+
|
31
|
+
public string data2 { get; set; }
|
32
|
+
|
33
|
+
public string data3 { get; set; }
|
34
|
+
|
35
|
+
public List<int> data4 { get; set; }
|
36
|
+
|
37
|
+
public List<int> data5 { get; set; }
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
static void Main(string[] args)
|
44
|
+
|
45
|
+
{
|
46
|
+
|
47
|
+
dataModel model = new dataModel();
|
48
|
+
|
49
|
+
List<dataModel> list = new List<dataModel>();
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
model.data1 = "値1";
|
54
|
+
|
55
|
+
model.data1 = "値2";
|
56
|
+
|
57
|
+
model.data1 = "値3";
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
List<int> for_data4 = new List<int>();
|
62
|
+
|
63
|
+
List<int> for_data5 = new List<int>();
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
for(int i = 0; i < 10; i++)
|
68
|
+
|
69
|
+
{
|
70
|
+
|
71
|
+
for_data4.Add(i);
|
72
|
+
|
73
|
+
for_data5.Add(i * 10);
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
model.data4 = for_data4;
|
80
|
+
|
81
|
+
model.data5 = for_data5;
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
list.Add(model);
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
Console.WriteLine(string.Join(" ", list[0].data5));
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
Console.ReadKey();
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
```
|