What's the difference between an argument and a parameter?

后端 未结 30 1925
北恋
北恋 2020-11-22 01:08

When verbally talking about methods, I\'m never sure whether to use the word argument or parameter or something else. Either way the other people know what

30条回答
  •  旧时难觅i
    2020-11-22 01:42

    According to Joseph's Alabahari book "C# in a Nutshell" (C# 7.0, p. 49) :

    static void Foo (int x)
    {
        x = x + 1; // When you're talking in context of this method x is parameter
        Console.WriteLine (x);
    }
    static void Main()
    {
        Foo (8); // an argument of 8. 
                 // When you're talking from the outer scope point of view
    }
    

    In some human languages (afaik Italian, Russian) synonyms are widely used for these terms.

    • parameter = formal parameter
    • argument = actual parameter

    In my university professors use both kind of names.

提交回复
热议问题