Resource strings

Top  Previous  Next

What is translated > Variables > Resource strings


Delphi compiler has built-in support for resource strings. In Delphi there is a complex management of modules  Delphi2C# makes resource strings to normal string constants



SIndexError  = 'Index out of bounds: %d';


gets translated to:


public static string SIndexError = "Index out of bounds: %d";



In the code for Delphi2C# there is an additional makeshift. TResStringRec is rewritten as:


public struct TResStringRec


  //public Pointer<HMODULE> Module;

  //public Pointer<uint> Module;

  //public uint Identifier;


  public static implicit operator TResStringRec(string s)


    return new TResStringRec() { FMessage = s }; 



  public string FMessage {get; set;}



The implicit operator lets compile calls like:


ConvertError(new Pointer<TResStringRec>(SFormatTooLong));


In a constructor of an Exception the message is fetched by:


  public Exception(Pointer<TResStringRec> ResStringRec)

   : base(ResStringRec.Deref().FMessage)




This page belongs to the Delphi2C# Documentation

Delphi2C# home  Content