As of .NET 9, there is no builtin binary serialization technology in .NET.
You can, however, use BinaryReader and BinaryWriter and manually serialize similar as you have demonstrated with Java.
BinaryReader
BinaryWriter