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

推荐订阅源

The Cloudflare Blog
Microsoft Security Blog
Microsoft Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
LangChain Blog
W
WeLiveSecurity
P
Proofpoint News Feed
月光博客
月光博客
NISL@THU
NISL@THU
L
LINUX DO - 最新话题
Webroot Blog
Webroot Blog
T
Threatpost
Y
Y Combinator Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Threat Research - Cisco Blogs
Vercel News
Vercel News
Jina AI
Jina AI
阮一峰的网络日志
阮一峰的网络日志
S
Schneier on Security
J
Java Code Geeks
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
小众软件
小众软件
MyScale Blog
MyScale Blog
N
News and Events Feed by Topic
Stack Overflow Blog
Stack Overflow Blog
有赞技术团队
有赞技术团队
The Hacker News
The Hacker News
Schneier on Security
Schneier on Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
Recent Announcements
Recent Announcements
S
Security @ Cisco Blogs
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Securelist
T
The Exploit Database - CXSecurity.com
云风的 BLOG
云风的 BLOG
C
Cisco Blogs
雷峰网
雷峰网
量子位
Google DeepMind News
Google DeepMind News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Spread Privacy
Spread Privacy
L
Lohrmann on Cybersecurity
I
Intezer
T
The Blog of Author Tim Ferriss
G
GRAHAM CLULEY
D
DataBreaches.Net
V
Vulnerabilities – Threatpost
P
Privacy & Cybersecurity Law Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
罗磊的独立博客

博客园 - 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)    收藏  举报