News for hackers. Stuff that matters.
Re:Yes, PHP is faster than C# by Someone on Wednesday March 16, 2022 @08:34PM (#30706050)
If you know the file isn’t too large, there also is File.ReadAllBytes (https://docs.microsoft.com/en-us/dotnet/api/system.io.file.r...)

My C# is very rusty (no pun intended) but I would guess the core of the program could be something like

  File.ReadAllBytes("file.bin").Where(x => x == '1').Count()
And nitpick: the code you gave has a bug. file.Read can return less than 4096. If so, you should only loop over the part of the buffer it filled.

There are no comments on this comment yet.