VB和隐式转换 [英] VB and implicit conversions

查看:71
本文介绍了VB和隐式转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个隐式转换设置在一个程序集中从Stream到

别的东西。在C#中,它可以工作。在VB中它没有。


VB是否支持隐式转换?如果是这样,任何想法为什么它会在

a C#程序中运行而不是VB?

-

Chad Z. Hower(又名Kudzu) - http://www.hower.org/Kudzu/

编程是一种反击的艺术形式

ELKNews - 获取免费副本 http://www.atozedsoftware.com

I have an implicit conversion set up in an assembly from a Stream to
something else. In C#, it works. In VB it does not.

Does VB support implicit conversions? And if so any idea why it would work in
a C# program but not VB?
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

推荐答案

乍得,


不,VB在当前版本中不支持隐式转换。也就是说,它不支持非原始类型的隐式转换。只有Whidbey

才会支持(并且希望在使用隐式运算符时,它会产生与C#生成的代码兼容的代码。)在

同时,你必须使用DirectCast关键字取消装箱物品。


克劳斯


" ; Chad Z. Hower aka Kudzu < CP ** @ hower.org> schrieb im Newsbeitrag

新闻:Xn ****************** @ 127.0.0.1 ...
Chad,

no, VB doesn''t support implicit castings in the current version. That is, it
doesn''t support implicit castings from non-primitive types. Only Whidbey
will support that (and hopefully it will be produce code that is compatible
with the code generated by C# when using the implicit operator); in the
meanwhile, you have to use the DirectCast keyword to unbox an object.

Klaus

"Chad Z. Hower aka Kudzu" <cp**@hower.org> schrieb im Newsbeitrag
news:Xn******************@127.0.0.1...
我有一个隐式转换在程序集中从Stream设置为
其他内容。在C#中,它可以工作。在VB中它没有。

VB是否支持隐式转换?如果是这样,任何想法为什么它会在C#程序中运行
而不是VB?

-
Chad Z. Hower(又名Kudzu) - http://www.hower.org/Kudzu/
编程是一种艺术形式反击

ELKNews - 在 http:// www获取免费副本.atozedsoftware.com
I have an implicit conversion set up in an assembly from a Stream to
something else. In C#, it works. In VB it does not.

Does VB support implicit conversions? And if so any idea why it would work in a C# program but not VB?
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com



" Klaus L?ffelmann" < FO *********** @ loeffelmann.de>写在

新闻:40 ********************** @ news.freenet.de:
"Klaus L?ffelmann" <fo***********@loeffelmann.de> wrote in
news:40**********************@news.freenet.de:
Whidbey将支持它(并且希望它将生成与使用隐式
运算符时由C#生成的代码兼容的代码);同时,你必须使用DirectCast关键字来取消打开一个对象。
Whidbey will support that (and hopefully it will be produce code that is
compatible with the code generated by C# when using the implicit
operator); in the meanwhile, you have to use the DirectCast keyword to
unbox an object.




Ack。 :(


我明白VB和C#之间存在差异。但MS怎么能把这样的东西留下来呢?Esp来自VB,国语反型

安全。你可以在哪里字符串=整数。:(


你能给我一个DirectCast的例子吗?

-

Chad Z. Hower(又名Kudzu) - http://www.hower.org/Kudzu/

编程是一种反击的艺术形式

ELKNews - 获取你的 http://www.atozedsoftware.com 上的免费副本



Ack. :(

I understand that there are differences between VB and C#. But how can MS
leave someting like this out? Esp from VB, the king language of anti type
safety. Where you could string = integer. :(

Can you give me an example of DirectCast?

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com


" Chad Z. Hower aka Kudzu"< cp ** @ hower.org> schrieb
"Chad Z. Hower aka Kudzu" <cp**@hower.org> schrieb
我在一个程序集中设置隐式转换在C#中,它可以正常工作。在VB中它没有。

VB是否支持隐式转换?如果所以任何想法为什么它会在C#程序中工作而不是VB?
I have an implicit conversion set up in an assembly from a Stream to
something else. In C#, it works. In VB it does not.

Does VB support implicit conversions? And if so any idea why it would
work in a C# program but not VB?




代码?

-

Armin


如何报价以及原因:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html



Code?
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


这篇关于VB和隐式转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆