using System;
public class Propertier {
public string ReadOnlyPlease { get; private set; }
public Propertier() { ReadOnlyPlease="As initialised"; }
public void Method() { ReadOnlyPlease="This might be changed internally"; }
public override string ToString() { return String.Format("[{0}]",ReadOnlyPlease); }
}
public class Program {
static void Main() {
Propertier p=new Propertier();
Console.WriteLine(p);
// p.ReadOnlyPlease="Changing externally!";
// Console.WriteLine(p);
// error CS0272: The property or indexer `Propertier.ReadOnlyPlease' cannot be used in this context because the set accessor is inaccessible
// That's good and intended.
// But...
p.Method();
Console.WriteLine(p);
}
}
dXNpbmcgU3lzdGVtOwoKcHVibGljIGNsYXNzIFByb3BlcnRpZXIgewoJcHVibGljIHN0cmluZyBSZWFkT25seVBsZWFzZSB7IGdldDsgcHJpdmF0ZSBzZXQ7IH0KCglwdWJsaWMgUHJvcGVydGllcigpICB7IFJlYWRPbmx5UGxlYXNlPSJBcyBpbml0aWFsaXNlZCI7IH0KCXB1YmxpYyB2b2lkIE1ldGhvZCgpIHsgUmVhZE9ubHlQbGVhc2U9IlRoaXMgbWlnaHQgYmUgY2hhbmdlZCBpbnRlcm5hbGx5IjsgfQoJcHVibGljIG92ZXJyaWRlIHN0cmluZyBUb1N0cmluZygpIHsgcmV0dXJuIFN0cmluZy5Gb3JtYXQoIlt7MH1dIixSZWFkT25seVBsZWFzZSk7IH0KfQoKcHVibGljIGNsYXNzIFByb2dyYW0gewoJc3RhdGljIHZvaWQgTWFpbigpIHsKCQlQcm9wZXJ0aWVyIHA9bmV3IFByb3BlcnRpZXIoKTsKCQlDb25zb2xlLldyaXRlTGluZShwKTsKCi8vCQlwLlJlYWRPbmx5UGxlYXNlPSJDaGFuZ2luZyBleHRlcm5hbGx5ISI7Ci8vCQlDb25zb2xlLldyaXRlTGluZShwKTsKCgkJLy8gZXJyb3IgQ1MwMjcyOiBUaGUgcHJvcGVydHkgb3IgaW5kZXhlciBgUHJvcGVydGllci5SZWFkT25seVBsZWFzZScgY2Fubm90IGJlIHVzZWQgaW4gdGhpcyBjb250ZXh0IGJlY2F1c2UgdGhlIHNldCBhY2Nlc3NvciBpcyBpbmFjY2Vzc2libGUKCQkvLyBUaGF0J3MgZ29vZCBhbmQgaW50ZW5kZWQuCgoJCS8vIEJ1dC4uLgoJCXAuTWV0aG9kKCk7CgkJQ29uc29sZS5Xcml0ZUxpbmUocCk7Cgl9Cn0=