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

后端 未结 30 1924
北恋
北恋 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条回答
  •  故里飘歌
    2020-11-22 01:58

    The use of the terms parameters and arguments have been misused somewhat among programmers and even authors. When dealing with methods, the term parameter is used to identify the placeholders in the method signature, whereas the term arguments are the actual values that you pass in to the method.

    MCSD Cerfification Toolkit (Exam 70-483) Programming in C#, 1st edition, Wrox, 2013

    Real-world case scenario

    // Define a method with two parameters
    int Sum(int num1, int num2)
    {
       return num1 + num2;
    }
    
    // Call the method using two arguments
    var ret = Sum(2, 3);
    

提交回复
热议问题