[IronPython] protected set { }

Matthew Barnard m.stephen.barnard at gmail.com
Wed May 14 14:27:04 PDT 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://lists.ironpython.com/pipermail/users-ironpython.com/attachments/20080514/36ccd54c/attachment.htm>


More information about the Users mailing list