Skip to content

Add Extension Properties #5811

Answered by HaloFour
grofit asked this question in Language Ideas
Feb 21, 2022 · 3 comments · 16 replies
Discussion options

You must be logged in to vote

See: #5498 dotnet/roslyn#11159

The team is exploring syntax like the following which would enable any kind of extension member:

public extension PlayerExtensions of Player {
    public int Health {
        get => this.Stats[StatTypes.Health];
        set => this.stats[StatTypes.Health] = value;
    }
}

The exact syntax/keywords for declaring the extension is still up for discussion.

Replies: 3 comments 16 replies

Comment options

You must be logged in to vote
6 replies
@CyrusNajmabadi
Comment options

@IvanPizhenko
Comment options

@CyrusNajmabadi
Comment options

@nxrighthere
Comment options

@KennethHoff
Comment options

Answer selected by grofit
Comment options

You must be logged in to vote
3 replies
@MemeDeveloper
Comment options

@CyrusNajmabadi
Comment options

@CyrusNajmabadi
Comment options

Comment options

You must be logged in to vote
7 replies
@CyrusNajmabadi
Comment options

@HaloFour
Comment options

@jamesford42
Comment options

@HaloFour
Comment options

@JustinMinnaar
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet