关于方法的ref
2024-08-24 21:49:10
没有ref的方法时:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
int number = ;
Test(number);
Console.WriteLine(number);//输出结果还是10,方法并没有改变number的值
Console.ReadKey();
} static int Test(int a)
{
a = ;
} }
}
有ref的方法时://ref 双向传递值
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
int number = ;
Test(ref number);
Console.WriteLine(number);//输出结果是100,方法改变了number的值
Console.ReadKey();
} static int Test(ref int a)
{
a = ;
} }
}
最新文章
- eclipse build workspace太慢或者 js出错问题解决
- centos为用户增加ssh key
- jsQunit
- 《零成本实现Web性能测试:基于Apache JMeter》读书笔记
- LTE Module User Documentation(翻译15)——示例程序、参考场景以及故障检测和调试技巧
- 解决org.openqa.selenium.WebDriverException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms org.springframework.beans.BeanInstantiation
- XML相关操作
- Spring Boot 所提供的配置优先级顺序
- XPOSED-LUA
- C#向C++编写的DLL传递字符串参数的办法
- Oracle的用户管理,授权及备份
- [Python]获取子线程异常信息
- react router 4.0以上的路由应用
- 随机手机号和身份证号码(python)
- 仿EXCEL插件,智表ZCELL产品V1.5 版本发布,IE8/9完全兼容
- (原创)列主元Gauss消去法的通用程序
- 数组 this.setData快捷赋值
- hdu 5676 ztr loves lucky numbers 打表+二分
- 阿里云rds 备份和还原
- [sql]生产库全备/mysql库体积大小查看