Resolved Help. CS0229 + CS0121 error.

emocharo

New member
Joined
Apr 14, 2022
Messages
4
Programming Experience
Beginner
C#:
public class PlayerMovementState
    {
        protected PlayerMovementStatemachine stateMachine;
        public PlayerMovementState(PlayerMovementStatemachine playerMovementStateMachine)
        {
            stateMachine = playerMovementStateMachine;
            //CS0229: Ambugity between 'PlayerMovementState.stateMachine' and 'PlayerMovementState.stateMachine

        }
        public class PlayerWalkingState : PlayerMovementState
        {
            public PlayerWalkingState(PlayerMovementStatemachine playerMovementStateMachine) : base(playerMovementStateMachine)
            {                                                                                   //C20121 The call is ambugious between the following methods or properties 'PlayerMovementState.PlayerMovementState(PlayerMovementStateMachine)' and 'PlayerMovementState.PlayerMovementState(PlayerMovementStateMachine)'

            }
        }
    }
}
 
Last edited:
Please post your code and error messages as text in code tags. You make it extremely difficult for people using mobile devices (in addition to eating into their data usage quotas).
 
Have you done a full build yet, or are those errors just from the squiggly red lines while you are still typing in the code?
 
They're just from the red lines. Do I need to finish the full build for them to go away on their own? This is my first project that I started not long ago and I'm very new so I was unsure.
 
The first thing you should do is move the declaration of the PlayerWalkingState class out of the definition of the PlayerMovementState class. It's very rare that nesting types is a good idea - even structures - and it definitely doesn't seem to be here. Almost always, each type should be defined in its own code file that is named after the type. The only exception I make to that rule is using a single Enumerations.cs file for all enumerations, because they are such simple and, generally, small types.

See if that has any impact on those error messages but I would suggest that you do a full build too and see what errors and warnings may be listed.
 
The first thing you should do is move the declaration of the PlayerWalkingState class out of the definition of the PlayerMovementState class. It's very rare that nesting types is a good idea - even structures - and it definitely doesn't seem to be here. Almost always, each type should be defined in its own code file that is named after the type. The only exception I make to that rule is using a single Enumerations.cs file for all enumerations, because they are such simple and, generally, small types.

See if that has any impact on those error messages but I would suggest that you do a full build too and see what errors and warnings may be listed.
Thank you!
 
Back
Top Bottom