mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-10 00:36:48 +02:00
C#: default parameter values
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user