© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
5 replies
2spooky2play

✅ confused by this error

class Player(Vector2 position, Vector2 size) {
    public Vector2 Position { get; } = position;
    public Vector2 Velocity { get; private set; } = Vector2.Zero;
    public Vector2 Size { get; } = size;

    public Rectangle GetRect() {
        return new(Position, Size);
    }

    public void Input() {
        float dt = GetFrameTime();
        Velocity.X = 0.0f;
    }
}
class Player(Vector2 position, Vector2 size) {
    public Vector2 Position { get; } = position;
    public Vector2 Velocity { get; private set; } = Vector2.Zero;
    public Vector2 Size { get; } = size;

    public Rectangle GetRect() {
        return new(Position, Size);
    }

    public void Input() {
        float dt = GetFrameTime();
        Velocity.X = 0.0f;
    }
}

Cannot modify the return value of 'Player.Velocity' because it is not a variable
Cannot modify the return value of 'Player.Velocity' because it is not a variable
in the
Input
Input
method

all i am doing is modifying the field of the struct, why is that a problem?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

confused on this error
C#CC# / help
2y ago
❔ confused about Error controller
C#CC# / help
4y ago
✅ Confused by constant errors regarding class extension.
C#CC# / help
3y ago