请任何人在结构上帮助我 [英] Please anyone help me on structures
本文介绍了请任何人在结构上帮助我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用循环创建结构并访问其元素
有可能吗?
I want to create a structure and acess it''s elements using a loop
Is it possible?
<StructLayout(LayoutKind.Sequential)> _
Private Structure data
Public a As Integer
Public b As sort
Public c As sort
Public d As Integer
Public e As Integer
End Structure
Dim dat as data 'OBJECT TO STR
Dim ptr As IntPtr = AllocHGlobal(SizeOf(dat))
StructureToPtr(dat, ptr, True)
现在,我创建了一个指针"ptr"
问题是我想使用循环访问结构的成员.
有可能吗?
Now I have created a pointer "ptr"
The problem is that I want to acess the members of structure using a loop.
Is it possible?
for i as integer=0 to 6
ptr(i)=44
next
推荐答案
是的,谷歌"VB.net反射".反射允许您在运行时检查类型.
Yes, Google "VB.net reflection". Reflection allows you to inspect types at runtime.
为什么不创建整数集合(或数组)呢?您可以遍历那些对象.
Why don''t you create a collection (or an array) of integers instead? You can iterate through those objects.
这篇关于请任何人在结构上帮助我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文