none
How do i measure the size of a string??? RRS feed

  • Question

  •  Hi,

    How do i check the size of a string...???

    For example say i have a string like this..

    Code Block
    <employee><name>Dave<name><address>Northhampshire</address></employee>

     

     

    I need to know how much size its going to take in memory in terms of KB/MB.

    Requirement is,we have a server which sends back a huge response xml in case of blind searches and hence the client app seems to choke.Need to measure the size of the response xml and basically make a decision whether to render the response on to the screen or not.So say if the response chunk is > 3 MB then we can abort displaying the results to the user and instead can show an info message.

     

    Thanks in advance for any possible solutions.

    Mmx

    Monday, November 26, 2007 8:20 AM

Answers


  • use :

    System.Text.ASCIIEncoding.Unicode.GetByteCount(s);
    System.Text.ASCIIEncoding.ASCII.GetByteCount(s);

    Depending on the encoding you intend to use.



    more...


    Monday, November 26, 2007 8:59 AM

All replies


  • use :

    System.Text.ASCIIEncoding.Unicode.GetByteCount(s);
    System.Text.ASCIIEncoding.ASCII.GetByteCount(s);

    Depending on the encoding you intend to use.



    more...


    Monday, November 26, 2007 8:59 AM
  • Seems to be a strange design, just to check the size. You rather check the input for your search or display the response in parts.
    Monday, November 26, 2007 9:37 AM