I'm trying to save a string to a filestream.
The documentation says that I should use an encoder class, for example ASCIIEncoding, to implement this. (i.e. use the GetBytes method to create ByteArray and then write this to the stream).
OK, fair enough, BUT
When I try to use the exact code that is demonstrated, I get "unknown identifier" when I reference the ASCIIEncoding class, for example see below:
This is the c# Code, I'm trying to convert to Delphi.Net:
using System;
using System.Text;
class ASCIIEncodingExample {
public static void Main() {
// The encoding.
ASCIIEncoding ascii = new ASCIIEncoding();
// --------------------------
----------
----------
----------
----------
---------
Now I've tried the following in delphi:
Uses
System,
System.Text // This doesn't compile
System.Object;
var
Ascii : ASCIIEncoding; // This doesn't compile
Ascii : System.Text.ASCIIEncoding;
// This doesn't compile
Nothing works - the system doesn't know anything about the " ASCIIEncoding" class.
Can anyone please show me how to reference and use the ASCIIEncoding class (the GetBytes method) in Delphi 2006?
Thanks
Steve
Start Free Trial