VB.Net调用新的没有赋值 [英] VB.Net calling New without assigning value
本文介绍了VB.Net调用新的没有赋值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 C#
我可以这样做:
new SomeObjectType abc,10);
换句话说,我可以调用new而不将创建的实例赋给任何变量。但是,在 VB.Net
看来我不能做同样的事情。
New SomeObjectType(abc,10)'语法错误
在 VB.Net
?
解决方案
a href =http://stackoverflow.com/questions/2648700/2649893#2649893>回答
所以这应该可以工作:
使用New SomeObjectType(abc,10)
pre>
结束于
In
C#
I can do this:new SomeObjectType("abc", 10);
In other words, I can call new without assigning the created instance to any variable. However, in
VB.Net
it seems I cannot do the same thing.New SomeObjectType("abc", 10) ' syntax error
Is there a way to do this in
VB.Net
?解决方案See the answers to this other SO Answer
So this should work:
With New SomeObjectType("abc", 10) End With
这篇关于VB.Net调用新的没有赋值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文