string_char_byte
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
string_char_byte [2018/01/24 11:08] – wolfgangriedmann | string_char_byte [2018/08/20 04:04] (current) – wolfgangriedmann | ||
---|---|---|---|
Line 10: | Line 10: | ||
That was possible in VO or other Win32 languages, but it is not more correct in .NET. | That was possible in VO or other Win32 languages, but it is not more correct in .NET. | ||
In .NET, if reading binary data, you need to use variables defined as '' | In .NET, if reading binary data, you need to use variables defined as '' | ||
- | < | + | < |
aBitmap := File.ReadAllBytes( " | aBitmap := File.ReadAllBytes( " | ||
If you are reading text data, you can read it into a string: | If you are reading text data, you can read it into a string: | ||
- | < | + | < |
cBuffer := File.ReadAllText( " | cBuffer := File.ReadAllText( " | ||
Line 22: | Line 22: | ||
To convert byte arrays to string, there are conversion functions. Please look at the Encoding class in the System.Text namespace in the .NET framework documentation. | To convert byte arrays to string, there are conversion functions. Please look at the Encoding class in the System.Text namespace in the .NET framework documentation. | ||
- | < | + | < |
local cString as string | local cString as string | ||
Line 28: | Line 28: | ||
The inverse process is also possible: | The inverse process is also possible: | ||
- | < | + | < |
local cString as string | local cString as string | ||
Line 36: | Line 36: | ||
To build a string from a char array is very simple, you can use the constructor of the string class: | To build a string from a char array is very simple, you can use the constructor of the string class: | ||
- | < | + | < |
local cString as string | local cString as string | ||
Line 42: | Line 42: | ||
For the inverse operation (from a string to a char array) you can use a method of the string class: | For the inverse operation (from a string to a char array) you can use a method of the string class: | ||
- | < | + | < |
local aChars as char[] | local aChars as char[] | ||
aChars := cString: | aChars := cString: | ||
+ | If you need to initialize a byte array (as every array), you need to write as follows: | ||
+ | <code visualfoxpro> | ||
+ | aBuffer := Byte[]{ 128 }</ |
string_char_byte.txt · Last modified: 2018/08/20 04:04 by wolfgangriedmann