C#: default parameter values

This commit is contained in:
Max Yankov 2013-08-17 23:09:07 +02:00
parent ccdc21900d
commit dd1a619360

View File

@ -482,12 +482,13 @@ namespace Learning
gear = newValue; gear = newValue;
} }
public void SpeedUp(int increment) // Method parameters can have defaut values. In this case, methods can be called with these parameters omitted
public void SpeedUp(int increment = 1)
{ {
_speed += increment; _speed += increment;
} }
public void SlowDown(int decrement) public void SlowDown(int decrement = 1)
{ {
_speed -= decrement; _speed -= decrement;
} }