回答編集履歴

3

foreach を使った方法を追記

2022/07/30 06:02

投稿

KOZ6.0
KOZ6.0

スコア2626

test CHANGED
@@ -28,3 +28,9 @@
28
28
  };
29
29
  ```
30
30
 
31
+ for を foreach に変えてもOK
32
+ ```C#
33
+ for(int j = 0; j < filePathList.Count; j++)
34
+
35
+ foreach (int j in Enumerable.Range(0, filePathList.Count))
36
+ ```

2

警告が出ないように

2022/07/30 05:38

投稿

KOZ6.0
KOZ6.0

スコア2626

test CHANGED
@@ -19,10 +19,10 @@
19
19
  NET6 の場合は
20
20
 
21
21
  ```C#
22
- // Action<object> を定義
22
+ // Action<object?> を定義
23
23
  Action<object?> action = (object? obj) => {
24
24
  if (obj is not object[] args) {
25
- throw new ArgumentNullException();
25
+ throw new ArgumentNullException(nameof(obj));
26
26
  }
27
27
  Process((SemaphoreSlim)args[0], (string)args[1], (string)args[2]);
28
28
  };

1

NET6 の場合

2022/07/30 05:26

投稿

KOZ6.0
KOZ6.0

スコア2626

test CHANGED
@@ -15,3 +15,16 @@
15
15
  new object[] { slim, filePathList[j], filePathList_Save[j] }));
16
16
  (略)
17
17
  ```
18
+
19
+ NET6 の場合は
20
+
21
+ ```C#
22
+ // Action<object> を定義
23
+ Action<object?> action = (object? obj) => {
24
+ if (obj is not object[] args) {
25
+ throw new ArgumentNullException();
26
+ }
27
+ Process((SemaphoreSlim)args[0], (string)args[1], (string)args[2]);
28
+ };
29
+ ```
30
+