i have this abstract class where i try to initialize dictionary with Objects but someone it wont let me
public abstract class ICharacterBody3DState
{
public static Dictionary<StateInput, ICharacterBody3DState> State = new Dictionary<StateInput, ICharacterBody3DState>()
{
StateInput.sprint=new StateInput(),
};
}
Each state is inheriting from this abstract class :
public class WalkingState : ICharacterBody3DState
{
}
but it gives me : CS0747: Invalid initializer member declarator. is there any way to initilize the abstract class Dictionary with Objects ?
put each key and value inside curly braces
{}and separated them with acomma. This is the right way to add items to your dictionary.