什么是参数和参数之间的区别? [英] What's the difference between an argument and a parameter?
问题描述
在口头上谈论的方法,我无法知道是否使用这个词的参数或参数的或别的东西。无论哪种方式,其他的人知道我的意思,但什么是正确的,什么是术语的历史?
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 I mean, but what's correct, and what's the history of the terms?
我是一个C#程序员,但我也想知道人们是否在不同的语言使用不同的术语。
I'm a C# programmer, but I also wonder whether people use different terms in different languages.
有关记录我自学成才没有计算机科学的背景。 (请不要告诉我读 code完成因为我问这个的人谁不已经有史蒂夫·麦康奈尔的副本其他人的利益的奇妙的书。)
For the record I'm self-taught without a background in Computer Science. (Please don't tell me to read Code Complete because I'm asking this for the benefit of other people who don't already have a copy of Steve McConnell's marvellous book.)
普遍的共识似乎是,它的确定在团队环境中交替使用这些术语。也许除了当你定义precise术语;那么你也可以使用正式的参数/参数和实际的参数/参数来消除歧义。
The general consensus seems to be that it's OK to use these terms interchangeably in a team environment. Except perhaps when you're defining the precise terminology; then you can also use "formal argument/parameter" and "actual argument/parameter" to disambiguate.
推荐答案
一个参数是一个方法定义的变量。当一个方法被调用,参数是你传递给方法的参数的数据。
A parameter is a variable in a method definition. When a method is called, the arguments are the data you pass into the method's parameters.
public void MyMethod(string myParam) { }
...
string myArg1 = "this is my argument";
myClass.MyMethod(myArg1);
这篇关于什么是参数和参数之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!