C++.Net Byte array?

How would I do this code,

1
2
3
array<byte> ^b = gcnew array<byte>();
//b = System::Text::Encoding::GetBytes("Hello world");
sock->Send(b);


Like in C# you would do,
1
2
3
byte[] b = byte[1024]; //or whatever buffer size.
b = System.Text.Encoding.GetBytes("Hello World");
sock.Send(b);


Thanks
1
2
3
4
5
6
7
8
9
10
11
12
using namespace System;
using namespace System::Text;

void func() //or anywhere in your code
{
     Encoding^ asciiEncoding = Encoding::ASCII;
     String^ asciiString = "Hello World";

     array<byte> ^b = gcnew array<byte>();
     b = asciiEncoding->GetBytes(asciiString);
     sock->Send(b);
}
Last edited on
Topic archived. No new replies allowed.