C# – ref

C# – ref

大家好,又见面了,我是全栈君。

The ref keyword causes an argument to be passed by reference, not by value. The effect of passing by reference is that any change to the parameter in the called method is reflected in the calling method. For example, if the caller passes a local variable expression or an array element access expression, and the called method replaces the object to which the ref parameter refers, then the caller’s local variable or the array element now refer to the new object.

Note: Do not confuse the concept of passing by reference with the concept of reference types. The two concepts are not the same. A method parameter can be modified byref regardless of whether it is a value type or a reference type. There is no boxing of a value type when it is passed by reference.

To use a ref parameter, both the method definition and the calling method must explicitly use theref keyword. An argument that is passed to a ref parameter must be initialized before it is passed.

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/116236.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 编写WordCount程序之一固定格式讲解

    编写WordCount程序之一固定格式讲解

    2022年3月13日
    36
  • MyEclipse激活成功教程 CI-2018.9.0版本

    MyEclipse激活成功教程 CI-2018.9.0版本介绍myeclipse是eclipse进化版,有很强大的功能,但是,它是收费的。这也是阻碍大多数人使用它的原因。作为学生,想使用该工具进行学习,但苦于资金有限,只能进行激活成功教程后再学习。本人找了很多的激活成功教程教程,最初感觉很简单,就打算直接开搞;但是,按照教程一步一步来,结果发现,自己就是不能成功。为此,我还安装了很多不同的版本,但由于没有找到根本原因,全都以失败告终。后来,仔细研究后才知道原因…

    2022年9月26日
    2
  • 系统调用(int 0x80)详解

    系统调用(int 0x80)详解1、系统调用初始化在系统启动时,会在sched_init(void)函数中调用set_system_gate(0x80,&system_call),设置中断向量号0x80的中断描述符:#defineset_system_gate(n,addr) _set_gate(&idt[n],15,3,addr)其中15表示此中断号对应的是陷阱门,注意,这个中断向量不是中断门描述符

    2025年11月6日
    3
  • vim查找高亮关键字_emacs和vim

    vim查找高亮关键字_emacs和vim如果我们在在打开的文件中使用Vim搜索功能并开启搜索高亮显示后怎么取消当前高亮显示搜索关键字呢?vim搜索高亮关键字如何取消,vim清除查询高亮搜索显示的方法下面站长为大家介绍vim搜索高亮关键字怎么取消,vim查询高亮搜索显示如果清除取消第一种方法:vim搜索高亮关键字怎么取消最简单的方法是再使用Vim搜索一个在文档中不存在的搜索关键词来覆盖当前高亮显示的搜索结果。第二种方法:vim查询高亮搜索…

    2022年9月23日
    5
  • mysql中去重 distinct 用法「建议收藏」

    mysql中去重 distinct 用法

    2022年2月10日
    371
  • Jenkins(3)拉取git仓库代码,执行python自动化脚本[通俗易懂]

    Jenkins(3)拉取git仓库代码,执行python自动化脚本[通俗易懂]前言python自动化的脚本开发完成后需提交到git代码仓库,接下来就是用Jenkins拉取代码去构建自动化代码了新建项目打开Jenkins新建一个自由风格的项目源码管理Repository

    2022年7月31日
    5

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号