惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
K
Kaspersky official blog
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
AWS News Blog
AWS News Blog
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Security @ Cisco Blogs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Recent Commits to openclaw:main
Recent Commits to openclaw:main
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
Attack and Defense Labs
Attack and Defense Labs
Jina AI
Jina AI
The Last Watchdog
The Last Watchdog
W
WeLiveSecurity
H
Help Net Security
V
Visual Studio Blog
宝玉的分享
宝玉的分享
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threat Research - Cisco Blogs
IT之家
IT之家
Hugging Face - Blog
Hugging Face - Blog
Latest news
Latest news
T
Tor Project blog
I
Intezer
美团技术团队
GbyAI
GbyAI
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
博客园 - 三生石上(FineUI控件)
Google DeepMind News
Google DeepMind News
Scott Helme
Scott Helme
Y
Y Combinator Blog
博客园 - 司徒正美
T
Tenable Blog
O
OpenAI News
N
News and Events Feed by Topic
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
V
Vulnerabilities – Threatpost
P
Palo Alto Networks Blog
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Threatpost
Google Online Security Blog
Google Online Security Blog
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
Help Net Security
Help Net Security

博客园 - gyhanonline

Function Point in Vbscript Window API in QTP Simulate click event using widows API. Static Constructor A Go Set program A Go Set program About Inherit Code for Inter-process communicate Integrity Level Test for publish blog by word 2007 托管为什么安全 The usage of intellisense in Vs .net 2005 我的面试(七) 关于singlton的一些问题 我的面试(六) 我的面试(五) 我的面试(四) 我的面试(三) 我的面试(二)
我的面试(四)补充1
gyhanonline · 2007-09-20 · via 博客园 - gyhanonline

突然想起来前天面试时,考官问我out参数和ref参数的区别。我当时答的是out是出的,ref可以来回传参。也就是说out参数是进不来的,而ref是可以进来了。
今天写代码试了试。从新整理一下关于out和ref的区别。

static void Function1(out int outParameter, ref int refParameter)
        {
            outParameter += 1;
            refParameter += 2;
        }
如果这样去写方法,编译是不通过的,系统会提示要为out参数赋初值。
         呵呵,其实就是outParameter 无论原来是啥,这一赋初值不就给覆盖了吗?也就是所谓的“传不进来”,而ref参数则没有“赋初值”的要求。简单的说就是“传进来”啥就用啥继续干活。
        那么out,ref参数个认为是在方法要求有多个返回值时使用,如果只要一个返回值时大可以用return。不要用out,ref搞得那么复杂。
         嘿嘿,基础的基础。大家认为关于out,ref还有啥,不妨说说哈。