0

I have a situation where I need to return the MAX of 2MB sized string from a method. I have seen some web services returning big XML contents as strings. What is the optimum size with which we should transact in value parameter passing and returning?

Srikanth P Vasist
  • 1,327
  • 2
  • 14
  • 26

3 Answers3

1

There is no technically correct answer to this because it's perfectly normal to pass any amount of characters as long as it's needed in your program. You need to evaluate if passing such a large string is valueable to your program. If it is, great. If it's not, find a way to shorten it or pass a file path or database identifier instead so the service can get the text from there itself.

nvoigt
  • 75,013
  • 26
  • 93
  • 142
  • 1
    Plus, it's important to note that strings are interned, so a 2 MB string won't be an issue. Unless, of course, you built that string by concatenating several million characters one at a time. – Daniel Mann Aug 27 '13 at 05:04
0

Is it OK to return a string with the size around 2 MB from a C#

if it is local (intranet,network) then it is mostly ok (unless the network is v v old). But, if you are passing it over the internet then you should consider the bandwidth of the client on which the data will be sent/received. Will it slow down your page or not etc. In most cases though it will be fine.

What is the optimum size with which we should transact in value parameter passing and returning

Any size that will not cause your application to slow down is fine.

Ehsan
  • 31,833
  • 6
  • 56
  • 65
0

It is completely okay, the only thing you should keep in mind is:

If a user is using 56kbps connection 2024/56=36.14 sec if this is not important for your case then no need to worry.

Zaheer Ahmed
  • 28,160
  • 11
  • 74
  • 110