Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is very unlikely that you will win any significant performance from this. However, if you need to save memory, this strategy may be appropriate.</p> <ul> <li><p>To convert a <code>string</code> to a <code>byte[]</code> for this purpose, use <code>Encoding.Default.GetBytes()</code><sup>[1]</sup>.</p></li> <li><p>To convert a <code>byte[]</code> back to a <code>string</code> for display or other string-based processing, use <code>Encoding.Default.GetString()</code>.</p></li> <li><p>You can make your code look nicer if you use extension methods defined on <code>string</code> and <code>byte[]</code>. Alternatively, you can wrap the <code>byte[]</code> in a wrapper type and put the methods there. Make this wrapper type a <code>struct</code>, not a <code>class</code>, otherwise it will incur extra heap allocations, which is what you’re trying to avoid.</p></li> </ul> <p>I want to warn you, though — you are throwing away the ability to have Unicode in your application. You should normally have all alarm bells go off every time you <em>think</em> you need to do this. It is best if you structure your code in such a way that you can easily go back to using <code>string</code> when memory sizes will have gone up and memory consumption stops being an issue.</p> <hr> <p><sub><sup>[1]</sup> <code>Encoding.Default</code> returns the current 8-bit codepage of the running operating system. The default for this on English-language Windows is Windows-1252, which is what you want. For Russian Windows it will be Windows-1251 (Cyrillic) etc.</sub></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload