如何将CastListList项类型转换为类对象 [英] How to Type cast ArrayList items to class objects
本文介绍了如何将CastListList项类型转换为类对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我是vb .net的新手,
我有一个ArrayList我将类对象存储在其中,
以后我想检索每个ArrayList项并输入到
类,
怎么能它完成了吗?
我使用CType进行投射但它抛出异常。
问候
ludy
解决方案
伙计,
你的意思是
\\\ />
dim myObject是myClass
myArraylist.Add(myObject)
DirectCast(myArrayList(0),myClass).WhatEver
///
我希望这会有所帮助,
Cor
" budy_ludy" < se ******* @ bermail.com的gmail.comschreef
新闻:11 ********************** @ i42g2000cwa.googlegr oups.com ...
>
大家好,
我是vb .net的新手,
我有一个ArrayList,我在其中存储类对象,
以后我想检索每个ArrayList项目和类型转换为
类,
如何完成?
我使用CType进行投射但它抛出异常。
问候
ludy
Hi Cor
以下是情况,
我试图将arraylist从function1传递给function2
接受类,
即使我使用Direct强制转换我也会出现异常。
公共类myClass
函数1()
--- --------
dim myObject是myClass
myArraylist.Add(myObject)
Functio n2(myArraylist.Item(0))
.......
.......
... ....
功能2(myClass)
-------------------
我在Function1内部调用Function2时会出现异常,即使在
DirectCast
Cor Ligthert [MVP]写道:
buddy,
你的意思是
\\\
dim myObject是myClass
myArraylist.Add(myObject)
DirectCast(myArrayList(0),myClass).WhatEver
/ //
我希望这会有所帮助,
Cor
" budy_ludy" < se ******* @ bermail.com的gmail.comschreef
新闻:11 ********************** @ i42g2000cwa.googlegr oups.com ...
大家好,
我是vb新手。 net,
我有一个ArrayList并且我在其中存储了类对象,
以后我想要检索每个ArrayList项并输入到
等级,
如何做?
我用CType进行投射但却抛出异常。
问候
ludy
Hello budy_ludy,
究竟是什么例外?
-Boo
Hi Cor
以下是情况,
我试图将arraylist从function1传递给function2
接受类,
即使我使用Direct cast我输入例外。
公共类myClass
Functi on1()
-----------
dim myObject是myClass
myArraylist.Add(myObject)
Function2(myArraylist.Item(0))
......
......
......
功能2(myClass)
-------------------
我在Function1内部调用Function2时出现异常,即使在
DirectCast
Cor Ligthert [MVP]写道:
>哥们,
你的意思是
\\\
dim myObject是myClass
myArraylist.Add (myObject)
DirectCast(myArrayList(0),myClass).WhatEver
///
我希望这会有所帮助,
budy_ludy ; < se ******* @ gmail.comschreef in bericht
新闻:11 ********************** @ i42g2000cwa.googleg roups .com ...
>>大家好,
我是vb .net的新手,
后来我想检索每个ArrayList项并输入类型转换为
类
它怎么可能是完成了吗?
我使用CType进行投射,但它抛出了异常。
问候
ludy
Hi All,
I am new to vb .net,
I have an ArrayList and i store class objects in it,
and later i want to retrieve each ArrayList items and type cast to the
class,
How can it be done ?
I used CType for casting but it is throwing exception.
regards
ludy
解决方案
buddy,
You mean something as
\\\
dim myObject is myClass
myArraylist.Add(myObject)
DirectCast(myArrayList(0),myClass).WhatEver
///
I hope this helps,
Cor
"budy_ludy" <se*******@gmail.comschreef in bericht
news:11**********************@i42g2000cwa.googlegr oups.com...>
Hi All,
I am new to vb .net,
I have an ArrayList and i store class objects in it,
and later i want to retrieve each ArrayList items and type cast to the
class,
How can it be done ?
I used CType for casting but it is throwing exception.
regards
ludy
Hi Cor
Below is the situation,
I am trying to pass the arraylist from function1 to the function2
which accepts class,
even if i type cast using Direct cast i get exception.
Public class myClass
Function1()
-----------
dim myObject is myClass
myArraylist.Add(myObject)
Function2(myArraylist.Item(0))
.......
.......
.......
Function2(myClass )
-------------------
I get exception when i call Function2 inside Function1 even after
DirectCast
Cor Ligthert [MVP] wrote:buddy,
You mean something as
\\\
dim myObject is myClass
myArraylist.Add(myObject)
DirectCast(myArrayList(0),myClass).WhatEver
///
I hope this helps,
Cor
"budy_ludy" <se*******@gmail.comschreef in bericht
news:11**********************@i42g2000cwa.googlegr oups.com...
Hi All,
I am new to vb .net,
I have an ArrayList and i store class objects in it,
and later i want to retrieve each ArrayList items and type cast to the
class,
How can it be done ?
I used CType for casting but it is throwing exception.
regards
ludy
Hello budy_ludy,
What Exception exactly?
-Boo
Hi Cor
Below is the situation,
I am trying to pass the arraylist from function1 to the function2
which accepts class,
even if i type cast using Direct cast i get exception.
Public class myClass
Function1()
-----------
dim myObject is myClass
myArraylist.Add(myObject)
Function2(myArraylist.Item(0))
......
......
......
Function2(myClass )
-------------------
I get exception when i call Function2 inside Function1 even after
DirectCast
Cor Ligthert [MVP] wrote:
>buddy,
You mean something as
\\\
dim myObject is myClass
myArraylist.Add(myObject)
DirectCast(myArrayList(0),myClass).WhatEver
///
I hope this helps,
Cor
"budy_ludy" <se*******@gmail.comschreef in bericht
news:11**********************@i42g2000cwa.googleg roups.com...
>>Hi All,
I am new to vb .net,
I have an ArrayList and i store class objects in it,
and later i want to retrieve each ArrayList items and type cast to
the
class,
How can it be done ?
I used CType for casting but it is throwing exception.
regards
ludy
这篇关于如何将CastListList项类型转换为类对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文