mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
C#: default parameter values
This commit is contained in:
parent
ccdc21900d
commit
dd1a619360
@ -482,12 +482,13 @@ namespace Learning
|
||||
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;
|
||||
}
|
||||
|
||||
public void SlowDown(int decrement)
|
||||
public void SlowDown(int decrement = 1)
|
||||
{
|
||||
_speed -= decrement;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user