“参数"vs“论据" [英] "Parameter" vs "Argument"
本文介绍了“参数"vs“论据"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我把 parameter 和 argument 弄混了,没有真正注意什么时候使用一个,什么时候使用另一个.
I got parameter and argument kind of mixed up and did not really pay attention to when to use one and when to use the other.
你能告诉我吗?
推荐答案
参数是变量,它是方法签名(方法声明)的一部分.参数是调用方法时使用的表达式.
A parameter is the variable which is part of the method’s signature (method declaration). An argument is an expression used when calling the method.
考虑以下代码:
void Foo(int i, float f)
{
// Do things
}
void Bar()
{
int anInt = 1;
Foo(anInt, 2.0);
}
这里i
和f
是参数,anInt
和2.0
是参数.
Here i
and f
are the parameters, and anInt
and 2.0
are the arguments.
这篇关于“参数"vs“论据"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文