[IronPython] protected set { }

Matthew Barnard m.stephen.barnard at gmail.com
Wed May 14 23:27:04 CEST 2008


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?

___________________________
Matthew Barnard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080514/36ccd54c/attachment.html>


More information about the Ironpython-users mailing list