Skip to content

example for method invocation says parameters are reversed, but they aren't reversed in the code snippet #44732

@Knar33

Description

@Knar33

Describe the issue or suggestion

https://learn.microsoft.com/en-us/dotnet/csharp/methods#method-invocation

In the third code snippet on this example it says "In this example, the named arguments are passed in the opposite order from the method's parameter list" but in the following example the parameters are in the same positional order:

namespace NamedMotorCycle;

class TestMotorcycle : Motorcycle
{
    public override int Drive(int miles, int speed) =>
        (int)Math.Round((double)miles / speed, 0);

    public override double GetTopSpeed() => 108.4;

    static void Main()
    {
        var moto = new TestMotorcycle();
        moto.StartEngine();
        moto.AddGas(15);
        int travelTime = moto.Drive(miles: 170, speed: 60);
        Console.WriteLine("Travel time: approx. {0} hours", travelTime);
    }
}
// The example displays the following output:
//      Travel time: approx. 3 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    ⌚ Not TriagedNot triagedin-prThis issue will be closed (fixed) by an active pull request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions