"参数" vs“参数” [英] "Parameter" vs "Argument"

查看:110
本文介绍了"参数" vs“参数”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:
参数或参数?

我得到了参数参数混合起来,并没有真正注意什么时候使用一个,什么时候使用另一个。

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.

请考虑以下代码:

Consider the following code:

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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆