code_junkie

Binary data in .NET (C++/CLI)

Nov 13th, 2011
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. byte data __gc [] = __gc new byte [100];
  2.  
  3. error C2726: '__gc new' may only be used to create an object with managed type
  4.  
  5. Byte data __gc [] = new Byte __gc [100];
  6.  
  7. cli::array<unsigned char>^ data = gcnew cli::array<unsigned char>(100);
  8.  
  9. cli::array<byte>^ data = gcnew cli::array<byte>(100);
  10.  
  11. #include "stdafx.h"
  12.  
  13. using namespace System;
  14.  
  15. int main(array<System::String ^> ^args)
  16. {
  17. cli::array<System::Byte^>^ a =
  18. gcnew cli::array<System::Byte^>(101);
  19.  
  20. a[1] = (unsigned char)124;
  21.  
  22. cli::array<unsigned char>^ b =
  23. gcnew cli::array<unsigned char>(102);
  24.  
  25. b[1] = (unsigned char)211;
  26.  
  27. Console::WriteLine(a->Length);
  28. Console::WriteLine(b->Length);
  29.  
  30. Console::WriteLine(a[1] + " : " + b[1]);
  31. return 0;
  32. }
  33.  
  34. 101
  35. 102
  36. 124 : 211
  37.  
  38. void fx (array<byte>^ data);
  39.  
  40. error C2061: syntax error : identifier 'array'
Add Comment
Please, Sign In to add comment