Mama Tate
Mama Tate

Reputation: 283

setting a variable in specific type in dictionary

Ok guys i have a dictionary like so:

mControllerTypes = new Dictionary<Type, ControllerBase>() 
{ 
    { Type.Follow, new ControllerFollowTap() },
    { Type.Guide, new ControllerGuide() },
    { Type.Poke, new ControllerPoke() },
    { Type.Swipe, new ControllerSwipe() }
};

My problem is that i want to access and edit a specific variables in the derived types in the dictionary instance. Like lets say in the ControllerSwipe i have a specific variable named SwipeLength which i don't want to include in the base class but want to set it in the dicitionary instance.How can i achieve this?

Upvotes: 0

Views: 32

Answers (1)

Magnus
Magnus

Reputation: 46909

((ControllerSwipe)mControllerTypes[Type.Swipe]).SwipeLength = 5;

Upvotes: 2

Related Questions