参数和参数有什么区别?(What's the difference between an argument and a parameter?)

编程入门 行业动态 更新时间:2024-10-28 05:24:46
参数和参数有什么区别?(What's the difference between an argument and a parameter?)

在口头谈论方法时,我永远不会确定是使用单词参数还是其他参数 。 无论哪种方式,其他人都知道我的意思,但是什么是正确的,这些术语的历史是什么?

我是C#程序员,但我也想知道人们是否使用不同语言的不同术语。

为了纪录我自学,没有计算机科学的背景。 (请不要告诉我阅读代码完成,因为我问这个是为了没有Steve McConnell的奇妙书的其他人的利益。)

概要

普遍的共识似乎是可以在团队环境中互换使用这些术语。 除了定义准确的术语之外, 那么你也可以使用“ 正式参数/参数”和“ 实际参数/参数”来消除歧义。

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?

I'm a C# programmer, but I also wonder whether people use different terms in different languages.

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.)

Summary

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.

最满意答案

参数是方法定义中的变量。 当调用一个方法时,参数是传递给方法参数的数据。

public void MyMethod(string myParam) { } ... string myArg1 = "this is my argument"; myClass.MyMethod(myArg1);

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);

更多推荐

本文发布于:2023-08-01 19:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1363813.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:参数   有什么区别   difference   argument   parameter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!