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

推荐订阅源

Hacker News: Ask HN
Hacker News: Ask HN
C
Cisco Blogs
The Hacker News
The Hacker News
T
Tor Project blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The GitHub Blog
The GitHub Blog
A
Arctic Wolf
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The Register - Security
The Register - Security
云风的 BLOG
云风的 BLOG
Simon Willison's Weblog
Simon Willison's Weblog
P
Palo Alto Networks Blog
Vercel News
Vercel News
C
CERT Recently Published Vulnerability Notes
I
InfoQ
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
M
MIT News - Artificial intelligence
I
Intezer
aimingoo的专栏
aimingoo的专栏
U
Unit 42
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LINUX DO - 热门话题
Microsoft Security Blog
Microsoft Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyberwarzone
Cyberwarzone
P
Proofpoint News Feed
P
Proofpoint News Feed
B
Blog
T
Threat Research - Cisco Blogs
博客园 - 叶小钗
Recorded Future
Recorded Future
Last Week in AI
Last Week in AI
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Know Your Adversary
Know Your Adversary
Engineering at Meta
Engineering at Meta
G
Google Developers Blog
PCI Perspectives
PCI Perspectives
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Application and Cybersecurity Blog
Application and Cybersecurity Blog
MyScale Blog
MyScale Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Schneier on Security
Schneier on Security
N
News | PayPal Newsroom
C
Cybersecurity and Infrastructure Security Agency CISA
H
Help Net Security
博客园 - 聂微东
H
Hackread – Cybersecurity News, Data Breaches, AI and More
G
GRAHAM CLULEY

博客园 - Roland

几个基本的计算机概念 Silverlight 5几个不错的新特性 无光驱采用U盘安装完整版xp javascript 日期格式化(转) jQuery URL Parser 帮助 .net环境下的javascript引擎汇总 使用ANTLR进行命令行参数解析 使用VSTA定制二次开发IDE(一) 探讨Antlr中文文法与英文文法的差异 .net与java中关于访问性的差异 垃圾回收浅谈 ASP.NET 页面对象模型[转自Msdnchina] dotnetnuke小结 dotnetnuke中皮肤管理小问题 DNN中令人困惑的用户管理机制 第一次学习dotnetnuke [转帖]怎样成为优秀的软件模型设计者? [转帖]论程序设计方法 让VFP回到旧时代
基础知识之vb.net的拷贝构造函数
Roland · 2005-05-27 · via 博客园 - Roland

在VB.net下可以定义拷贝构造函数了,定义方法为:
class sam
    sub new (byval obj as sam)
        '在此处编写拷贝的操作
    end sub
end class

虽然也称之为拷贝构造函数,但与C++下的概念还是有差别的。
在C++下有一默认的浅拷贝构造函数,可以实现按位赋值,而在VB.Net下需要手工实现。
不过关于浅拷贝与深拷贝的概念还是一样的。

因为不提供默认拷贝构造函数,所以vb.net下的拷贝构造函数没有太大意义。微软也建议采用实现ICloneable接口来实现对象的拷贝,而不是什么拷贝构造函数。

不过实现因为ICloneable.Clone方法返回的是Object类型,所以需要有一个强制类型转换的过程(采用DirectCast或者Ctype)。

这也许算是VB.NET中的一个小小的瑕疵吧!

posted @ 2005-05-27 09:22  Roland  阅读(1578)  评论(0)    收藏  举报