Welcome to Atalasoft Community Sign in | Help

More Property Wants – Polymorphic Set

I was writing some property heavy code and I realized that if I can write this code:

public void SetFoo(int x) { }
public void SetFoo(double y) { }
public void SetFoo(Rational z) { }

then I really want to have this syntax:

public int Foo {
    get { /* ... */ }
    set { /* ... */ }
    set (double) { /* ... */ }
    set {Rational) { /* ... */ }
}

.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }Because they’re the same, really.

In addition, I was to also see PropertyInfo.IsAssignableFrom(Type t) (although IsSettableFrom is better wording, the former matched the Type.IsAssignableFrom method) so that I can figure out from reflection if a set would throw.

Published Tuesday, December 15, 2009 1:26 PM by Steve Hawley

Comments

No Comments
Anonymous comments are disabled