   C# Restrictions on Pointers - A Load of Crap?
  I am trying to put 3 different integers into an array of bytes with C# so that I can send it out over a socket.  Now, with C++ I would just just bust out int pointers into the buffer and assign them, but with C# there is all of this unsafe business etc etc etc.  Out of curiosity, how are you supposed to do this *WITHOUT* pointers?  It seems like getting things into byte arrays is difficult without them.  Thanks. 
  There are several ways to do this. Off the top of my head, you could chain together a BinaryWriter with a NetworkStream on your Socket and just use the BinaryWriter as the interface to the socket. Or maybe you could use a BinaryWriter with a MemoryStream to create the Byte[] that you need to use the Socket''s Send() method. ;  BitConverter.GetBytes() is your friend.   Kami no Itte ga ore ni zettai naru! ;  You could just do something likeint a=1,b=2,c=3;byte[] buffer = new byte[sizeof(int) * 3];byte[] abuffer = BitConverter.GetBytes(a);byte[] bbuffer = BitConverter.GetBytes(b);byte[] cbuffer = BitConverter.GetBytes(c);//copy the three buffers into the one big buffer  You could do this any number of ways, iterate through and assign them manually, use a BinaryWriter (probably what I''d do, but I don''t have vs.net open and it''s late) etc.   Joel Martinezhttp://www.codecube.net/ ;  You can''t do it as conveniently as you can in C++.  This is the cost you pay when you have more enforcement of type safety (specifically, you lose many of the subversions of the type system that C++ acknowledges as useful and so permits) with an inexpressive type system.;  byte[] buffer = {1,2,3};TcpClient client = new Client();NetworkStream ns = client.GetStream();ns.Write(buffer,0,3);and modify the creation of client to suit however you need to do it in your project ;  Why don''t you just use unsafe? It''s not any less safe than when you do the same thing in C++. 