I am trying to copy an Ascii string to a byte array but am unable. How?
Here are the two things I have tried so far. Neither one works:
public int GetString (ref byte[] buffer, int buflen)
{
string mystring = "hello world";
// I have tried this:
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
buffer = encoding.GetBytes(mystring);
// and tried this:
System.Buffer.BlockCopy(mystring.ToCharArray(), 0, buffer, 0, buflen);
return (buflen);
}