Re: Do we have extention properties in C# 3.0?

Tech-Archive recommends: Speed Up your PC by fixing your registry



Peter Duniho wrote:
On Wed, 23 Jul 2008 17:11:48 -0700, Arne Vajhøj <arne@xxxxxxxxxx> wrote:
How should the syntax be to distinguish between
a method with no arguments and a property ?

Syntax for an extension property:

public int MyProperty(this SomeClass arg0)
{
get;
set;
}

Just because properties as declared now don't include an argument list, that doesn't mean they couldn't. There's enough other information in the declaration block to distinguish a property from a method, I believe.

No doubt there are other valid ways to allow the declaration of an extension property, but the above seems most straightforward and consistent to me.

It will require readers to check the body to see if something is
a method or a property.

Not very nice syntax.

Arne
.



Relevant Pages

  • Re: SCardGetStatusChange in .NET
    ... Here's my declaration for it: ... internal static extern int SCardGetStatusChange(int hContext, int dwTimeout, ... internal struct SCARD_READERSTATE { ... public int dwCurrentState; ...
    (microsoft.public.platformsdk.security)
  • Re: Do we have extention properties in C# 3.0?
    ... How should the syntax be to distinguish between ... public int MyProperty(this SomeClass arg0) ... No doubt there are other valid ways to allow the declaration of an extension property, but the above seems most straightforward and consistent to me. ...
    (microsoft.public.dotnet.languages.csharp)