Difference between arguments/parameters in C# [duplicate]

橙三吉。 提交于 2019-12-20 08:56:56

问题


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

What is the difference between an argument & a parameter in C#?

Are they the same thing?


回答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



回答2:


In the context of functions yes, they are the same, sometimes if you are talking about passing data to executables such as MyApp.exe /a:value /b:somethingelse, this might be refered to as arguments




回答3:


Typically, I refer to command-line arguments, as arguments. Arguments to a method or function I typically call parameters.

However, this isn't convention and both can be used interchangeably without people getting confused.




回答4:


they are used interchangeably but anyway to be accurate check this article



来源:https://stackoverflow.com/questions/1663705/difference-between-arguments-parameters-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!