I have created the below object:
public class GameProperties : ModelBase
{
private int _gameSpeed;
public virtual int GameSpeed
{
get { return _gameSpeed; }
set
{
_gameSpeed = value;
OnPropertyChanged("GameSpeed");
}
}
public void SetGameSpeed(int speed)
{
_gameSpeed = speed;
}
}
I set the GameSpeed property when loading my application:
GameProperties newProperty = new GameProperties();
newProperty.SetGameSpeed(4);
what i want to do is now reference the GameSpeed within another class. Can you please help with this as I am a new developer and can’t figure it out.
thank you
You could pass the
GamePropertiesreference to the other class either in the constructor or the method you are calling. For example:or in the constructor: