Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi.. I'm interested in using byte array in C# .net, and why .Net use this sort of array to store , save and transfer data specially in case of transferring data through network,for example Read() method in NetworkStream class :

C#
NetworkStream clientStream = tcpClient.GetStream();
byte[] message = new byte[4096];
clientStream.Read(message, 0, 4096);
Posted
Updated 17-Jul-14 7:26am
v3
Comments
ZurdoDev 17-Jul-14 11:20am    
I'd suggest googling for it. Seems like there should be some good articles on that.
CPallini 17-Jul-14 16:20pm    
Because .NET designers found somehow impractical sending oranges over the network.

I have worked on a similar project of transmitting data via network. The UI process was in .NET, we used an adapter (in C++/CLI) for converting data (both primitive and user defined) to binary array because the low level network API's expected the data in terms of byte array. Also we have to break down the larger data into chunks and transfer the same as byte array. Hence it was more or less a constraint for us to change the data types to byte array before transmitting.
 
Share this answer
 
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!
 
Share this answer
 
Comments
HDM91 17-Jul-14 11:09am    
its not homework , i am writing a program that transmit data through network and a question Came up in my mind that why we using byte array and why not we use for example a string or primitive datatype to transmit data to networkstream class? thank you
OriginalGriff 17-Jul-14 12:20pm    
"It's not homework".
Yeah, right...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900