[IronPython] protected set { }
Michael Foord
fuzzyman at voidspace.org.uk
Wed May 14 23:37:03 CEST 2008
Matthew Barnard wrote:
> public abstract class Object
> {
> protected string weakName = string.Empty;
>
> public string WeakName
> {
> get { return this.weakName; }
> protected set { this.weakName = value; }
> }
> }
>
> public class Derived
> {
> public Derived()
> {
> this.WeakName = "Hello";
> }
> }
>
> In C#:
> Derived obj = new Derived();
> Console.WriteLine(obj.WeakName)
> Hello
> obj.WeakName = "Fail";
> The property or indexer 'Object.WeakName' cannot be used in this
> context because the set accessor is inaccessible
>
> In IPy:
> >>> obj = Derived()
> >>> obj.WeakName = 'Succeed'
> >>> obj.WeakName
> 'Succeed'
>
> Is this expected behavior?
Yes.
Michael Foord
>
> ___________________________
> Matthew Barnard
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
More information about the Ironpython-users
mailing list