本文介绍了C#中的out和ref参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它们之间有什么区别?

我们何时何地应该使用OUT和REF?

编程示例?

RealWorld示例

..

谢谢。

非常感谢积极的讨论。

what is the difference between them?
when or where we should use OUT and REF?
Programming example?
RealWorld Example
..
thank you.
Positive discussion is appreciated.

推荐答案


int a;
Item(out a); // OK

int b;
Item(ref b); // Not Ok





参考参数适用于可能被修改的数据 out 参数用于函数的附加输出的数据(例如int.TryParse)已经使用某些东西的返回值。



欲了解更多详情,请访问以下链接:





Ref parameters are for data that might be modified, out parameters are for data that''s an additional output for the function (eg int.TryParse) that are already using the return value for something.

For more detail information please visit the following link:
The out and ref Paramerter in C#
What is the difference between out and ref in C#?



这篇关于C#中的out和ref参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 16:01
查看更多