mouthpiec
mouthpiec

Reputation: 4033

byte[] array size is equal to actual size of array in C#?

Does the byte[] array size reflects the same size of bytes to be transmitted if I need to transmit the file via a webservice?

E.G:

byte[] testarray = new byte[100000]

means that its size if transmitted will be approx 100,000 bytes (100kB)?

thanks

Upvotes: 3

Views: 8366

Answers (4)

John Alexiou
John Alexiou

Reputation: 29244

Without much detail, the answer is yes. testarray is a byte buffer of 100000 count. That is 100000/1024 = 97.6 KiB (damn you kB v. KiB SI standards)

Upvotes: 3

Christian Hayter
Christian Hayter

Reputation: 31071

Usually no, because all data has to be serialised into the appropriate format dictated by the binding or protocol that the service is using.

Different service technologies use different serialisers, WCF in particular is highly configurable. Your array could be transmitted as an XML fragment with one element per array element, a JSON string, old-style SOAP RPC format, base64 string, or whatever.

Upvotes: 0

Thorarin
Thorarin

Reputation: 48476

It depends what protocol you will be using for accessing the web service. If you're using SOAP over HTTP, there is going to be significant overhead, because the byte array will be transmitted as a base64 string. That would still mean an roughly a 8/6 increase in size, just over 130 kiB.

You may want to look into using MTOM. That will significantly reduce the overhead.

Another thing you may need to consider is that web service frameworks such as WCF sometimes have maximum message sizes. For the default WCF configuration, the message would be too large.

Upvotes: 2

Eiko
Eiko

Reputation: 25632

Yes, that is as long as you don't encode it differently.

Upvotes: 1

Related Questions