回答編集履歴
1
コードを変更
answer
CHANGED
@@ -10,11 +10,13 @@
|
|
10
10
|
public static class MyCSharpExtension {
|
11
11
|
// extension method の定義例
|
12
12
|
public static IEnumerable<byte> ReadBytes(this FileStream fs) {
|
13
|
+
byte[] buffer = new byte[4096];
|
13
14
|
for (;;) {
|
14
|
-
int
|
15
|
+
int len = fs.Read(buffer, 0, buffer.Length);
|
15
|
-
if (
|
16
|
+
if (len == 0)
|
17
|
+
break;
|
18
|
+
for (int i = 0; i < len; i++)
|
16
|
-
yield return
|
19
|
+
yield return buffer[i];
|
17
|
-
}
|
18
20
|
}
|
19
21
|
}
|
20
22
|
}
|