C#中参数/参数之间的区别 [英] Difference between arguments/parameters in C#
问题描述
可能的重复:
参数和参数有什么区别?
论点和论点有什么区别?C#中的一个参数?
What is the difference between an argument & a parameter in C#?
它们是一样的吗?
推荐答案
嗯,这两个关键字都没有出现在语言中,所以问题有点模糊.最好的办法是查看每个术语在 C# 语言规范(1.6.6.1参数")中的使用方式:
Well, neither keyword is present in the language, so the question is somewhat vague. The best that can be done is to look how each term is used in C# language specification (1.6.6.1 "Parameters"):
参数用于向方法传递值或变量引用.方法的参数从调用方法时指定的参数中获取其实际值.
Parameters are used to pass values or variable references to methods. The parameters of a method get their actual values from the arguments that are specified when the method is invoked.
因此,参数"指的是名称,而参数"指的是绑定到这些名称的值.例如:
So, "parameters" refer to names, and "arguments" refer to values bound to those names. E.g.:
void Foo(int x, int y); // x and y are parameters
Foo(1, 2); // 1 and 2 are arguments
这篇关于C#中参数/参数之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!