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

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
Vulnerabilities – Threatpost
Cloudbric
Cloudbric
G
GRAHAM CLULEY
S
Securelist
Schneier on Security
Schneier on Security
Help Net Security
Help Net Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Project Zero
Project Zero
Spread Privacy
Spread Privacy
P
Privacy International News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
T
Tailwind CSS Blog
博客园_首页
有赞技术团队
有赞技术团队
Simon Willison's Weblog
Simon Willison's Weblog
Stack Overflow Blog
Stack Overflow Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Latest news
Latest news
T
Tor Project blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Attack and Defense Labs
Attack and Defense Labs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
O
OpenAI News
J
Java Code Geeks
T
Tenable Blog
K
Kaspersky official blog
AWS News Blog
AWS News Blog
S
Security @ Cisco Blogs
The GitHub Blog
The GitHub Blog
T
Threatpost
月光博客
月光博客
H
Heimdal Security Blog
Security Latest
Security Latest
The Hacker News
The Hacker News
Y
Y Combinator Blog
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
C
Cisco Blogs
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
C
CERT Recently Published Vulnerability Notes
D
Docker
Google Online Security Blog
Google Online Security Blog
D
DataBreaches.Net
V
Visual Studio Blog
H
Help Net Security

博客园 - Avlee

ArcGIS Server Manager 登录失败的解决方法 利用ArcSDE C API读取ArcSDE Raster数据 倡议以赞助的形式成立一个博客园的开发团队(博客园商业化尚早) 在WebGIS中试用Microsoft Silverlight有感 The MSVC project of the cairo library(version 1.4.6) WebGIS团队启用二级域名 Building the cairo graphic library using msvc Adobe 将停止对Adobe SVG Viewer的支持! SVG Authoring Guidelines[转] Using Delegates with Data Readers to Control DAL Responsibility[转] 关于旧mdl程序向V8升级的问题 有了Flash和SVG,Adobe还想做什么呢? 基于Geomedia Professional平台的GIS应用开发(一) 根据权限创建页面上的功能按钮的一种简单有效的方法 如何让英文版的Adobe SVG Viewer显示中文文字 Adobe SVG Viewer 6.0 中自定义右键菜单 过年了,再忙也要回家...... 申请加入 “WebGIS” 团队 WebGIS团队刚刚成立
ArrayList.ToArray(Type) Or ArrayList.CopyTo(Array)
Avlee · 2006-01-05 · via 博客园 - Avlee

I thought ArrayList.ToArray(Type) was for intrinsic types (int, string etc.) but forgot that one the facilitites of OOP is that types that we define can be treated as instinsic types for most occasions. Today I came across a code that showed the use of ArrayList.ToArray(Type) for a type defined by the programmer.

...
return (Contact[])mContacts.ToArray(typeof(Contact));
...

here mConstacts is of type ArrayList, and Contact is a class.

I was doing the following till now :-

C# :-

Contact[] contacts = new Contact[mContacts.Count];

mContacts.CopyTo(contacts);

return contacts;

I have yet to peek into the IL to see the difference/similarity between the two approaches in terms of internals, but the first one at least requires less code and fits in a single line. :-)