teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

5

インデント修正

2020/10/01 02:04

投稿

退会済みユーザー
answer CHANGED
@@ -18,16 +18,16 @@
18
18
  //クラスを使用(コンストラクタで初期化)
19
19
  public static AAA[] array1 =
20
20
  {
21
- new AAA(1, "data1"),
21
+ new AAA(1, "data1"),
22
- new AAA(2, "data2"),
22
+ new AAA(2, "data2"),
23
- };
23
+ };
24
24
 
25
25
  //クラスを使用(プロパティで初期化)
26
26
  public static AAA[] array2 =
27
27
  {
28
- new AAA { Id= 1, Text="data1" },
28
+ new AAA { Id= 1, Text="data1" },
29
- new AAA { Id= 2, Text="data2" },
29
+ new AAA { Id= 2, Text="data2" },
30
- };
30
+ };
31
31
 
32
32
  //Tupleを使用
33
33
  public static (int Id, string Text)[] array3 =

4

少し修正

2020/10/01 02:04

投稿

退会済みユーザー
answer CHANGED
@@ -2,7 +2,7 @@
2
2
  public class AAA
3
3
  {
4
4
  public AAA()
5
- {
5
+ {
6
6
  }
7
7
 
8
8
  public AAA(int id, string text)
@@ -16,26 +16,25 @@
16
16
  }
17
17
 
18
18
  //クラスを使用(コンストラクタで初期化)
19
- public static AAA[] data1 =
19
+ public static AAA[] array1 =
20
20
  {
21
- new AAA(1, "data1"),
21
+ new AAA(1, "data1"),
22
- new AAA(2, "data2"),
22
+ new AAA(2, "data2"),
23
- };
23
+ };
24
24
 
25
25
  //クラスを使用(プロパティで初期化)
26
- public static AAA[] data2 =
26
+ public static AAA[] array2 =
27
27
  {
28
- new AAA { Id= 1, Text="data1" },
28
+ new AAA { Id= 1, Text="data1" },
29
- new AAA { Id= 2, Text="data2" },
29
+ new AAA { Id= 2, Text="data2" },
30
- };
30
+ };
31
31
 
32
32
  //Tupleを使用
33
- public static (int Id, string Text)[] data3 =
33
+ public static (int Id, string Text)[] array3 =
34
34
  {
35
35
  (1, "data1"),
36
36
  (2, "data2"),
37
37
  };
38
-
39
38
  ```
40
39
 
41
40
  こんなんでどうでしょう。

3

少し修正

2020/10/01 01:00

投稿

退会済みユーザー
answer CHANGED
@@ -30,10 +30,10 @@
30
30
  };
31
31
 
32
32
  //Tupleを使用
33
- public static Tuple<int, string>[] data3 =
33
+ public static (int Id, string Text)[] data3 =
34
34
  {
35
- new Tuple<int, string>(1, "data1"),
35
+ (1, "data1"),
36
- new Tuple<int, string>(2, "data2"),
36
+ (2, "data2"),
37
37
  };
38
38
 
39
39
  ```

2

一部削除

2020/10/01 00:55

投稿

退会済みユーザー
answer CHANGED
@@ -36,20 +36,6 @@
36
36
  new Tuple<int, string>(2, "data2"),
37
37
  };
38
38
 
39
- public class BBB : Tuple<int, string>
40
- {
41
- public BBB(int item1, string item2) : base(item1, item2)
42
- {
43
- }
44
- }
45
-
46
- //Tupleを使用その2
47
- public static BBB[] data4 =
48
- {
49
- new BBB(1, "data1"),
50
- new BBB(2, "data2"),
51
- };
52
-
53
39
  ```
54
40
 
55
41
  こんなんでどうでしょう。

1

少し修正

2020/10/01 00:52

投稿

退会済みユーザー
answer CHANGED
@@ -16,14 +16,14 @@
16
16
  }
17
17
 
18
18
  //クラスを使用(コンストラクタで初期化)
19
- public static AAA[] data2 =
19
+ public static AAA[] data1 =
20
20
  {
21
21
  new AAA(1, "data1"),
22
22
  new AAA(2, "data2"),
23
23
  };
24
24
 
25
25
  //クラスを使用(プロパティで初期化)
26
- public static AAA[] data1 =
26
+ public static AAA[] data2 =
27
27
  {
28
28
  new AAA { Id= 1, Text="data1" },
29
29
  new AAA { Id= 2, Text="data2" },