namespace ConsoleApplication1;
interface
type
Class1 = public class
private
method get_Prop : String; empty;
method set_Prop(Value : String); empty;
public
property Prop : String read get_Prop write set_Prop;
end;
Class2 = public class
public
property Prop : String private read private write;
end;
Program = class
public
class method Main(args: array of String): Int32;
end;
implementation
class method Program.Main(args: array of String): Int32;
begin
var c1 := new Class1;
var c2 := new Class2;
c1.Prop := 'OK'; // Public property with private accessors
c1.set_Prop('Why private accessor "set_Prop" is accessible here?');
c2.Prop := 'Error (E267) Property "Prop" on type "Class2" is read-only'; // Public property with private accessor. Same as Class1.
end;
end.
If the accessor names matches what it would be internally (get_Property on .NET, getProperty on Java, Property on Cocoa) the compiler will promote the method to match the property.
OK. Thanks.