Instead of something like this:
Func<bool> func;
bool Property {
get {return func();}
}
I want to be able to do something like this:
Property.get = () => booleanReturningExpression;
Is that possible, or can you get me closer to that fake syntax?
No, nothing like that is possible in pure C#. You can use fields or (
readonly) properties:and assign to it, but that’s not a very nice solution. If you need this feature for anything more than syntactic sugar, you could delegate from a property:
And you’d be able to set it very similarly. Alternatively, you could mimic delegates if you really wanted
Property.getand set a default method on a customPropertyclass. (I don’t know if this is possible in C#, but it is in VB.NET.)