That is not C++, which is likely to be your problem.
That is C# - and while they look superficially similar and share some common syntax they are completely different languages.
For example, your declaration of
bytes
in the first method:
byte[] bytes = ...
If C++ would be either:
byte bytes[] = ...
Or:
array<Byte>^bytes = ...
If you aren't trying to compile C# code as C++, then you need to show us exactly where the error is, and what message you get.