User Tools

Site Tools


string_char_byte

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
string_char_byte [2018/02/12 07:10] wolfgangriedmannstring_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 ''byte[]'', that means .NET array of bytes: In .NET, if reading binary data, you need to use variables defined as ''byte[]'', that means .NET array of bytes:
-<code>local aBitmap as byte[]+<code visualfoxpro>local aBitmap as byte[]
  
 aBitmap := File.ReadAllBytes( "c:\data\MyImage.png" )</code> aBitmap := File.ReadAllBytes( "c:\data\MyImage.png" )</code>
  
 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:
-<code>local cBuffer as string+<code visualfoxpro>local cBuffer as string
  
 cBuffer := File.ReadAllText( "c:\data\MyText.txt", Encoding.ASCII )</code> cBuffer := File.ReadAllText( "c:\data\MyText.txt", Encoding.ASCII )</code>
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.
-<code>local aBytes as byte[]+<code visualfoxpro>local aBytes as byte[]
 local cString as string local cString as string
  
Line 28: Line 28:
  
 The inverse process is also possible: The inverse process is also possible:
-<code>local aBytes as byte[]+<code visualfoxpro>local aBytes as byte[]
 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:
-<code>local aChars as char[]+<code visualfoxpro>local aChars as char[]
 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:
-<code>local cString as string+<code visualfoxpro>local cString as string
 local aChars as char[] local aChars as char[]
  
Line 48: Line 48:
  
 If you need to initialize a byte array (as every array), you need to write as follows: If you need to initialize a byte array (as every array), you need to write as follows:
-<code>local aBuffer as byte[]+<code visualfoxpro>local aBuffer as byte[]
  
 aBuffer := Byte[]{ 128 }</code> aBuffer := Byte[]{ 128 }</code>
string_char_byte.txt · Last modified: 2018/08/20 04:04 by wolfgangriedmann