C # watch refactoring course from itvdn. there is a class:

class Car(){ bool isSportCar; ... Car(bool isSportCar){ this.isSportCar = isSportCar; } ... } 

call the constructor method of the above class with a boolean value as an argument parameter:

 Car fastCar = new Car(isSportCar: true); 

The elementary format itself confuses us: NOTICE of a variable name, DOUBLE ... see for the first time instead of the usual value. Give a link to msdn who knows, I will not find ...

  • 3
    What language? .. And issue a code, please. - Pavel Mayorov
  • one
  • C #. Corrected. A separate section is not found. Do not kick the question, I do not usually ask. ABOUT! Thank. If you do not know the order! for sure. stupid ok k - i48
  • @vitidev: Maybe write a response? - VladD
  • So you yourself answered. Here is the text on the link: If the developer does not remember the order of the parameters, but knows their names, he can pass arguments in any order, first indicating the weight or height. CalculateBMI (weight: 123, height: 64); - i48

1 answer 1

These are named parameters . Useful in cases

  1. When you need to focus on the parameter, so that the reader immediately understands what true means.
  2. Allows you to call parameters in a different order.
  3. If the method takes a lot of parameters with default values, then only necessary ones can be specified. (without named parameters to fill the 5 positional parameter you have to fill in the previous 4, even if they have default values)