M
Mike
Hi, I am trying to figure out why I have to do this:
DIM u as TUser
'---------- Why is this necessary?
Dim s(10) as TSecurityName
u.security = s
'----------
in order to do assignments like so?
u.security(0) = "Normal"
u.security(1) = "Extra"
Background:
I have c structures that in VB, it looks like this:
Type TUser
...
Security(1 To 10) As String * 32
...
End type
So the Tuser structure has a field Security which is array of 10 of
asciiz string of length 32.
In VB.NET, the structures I have is
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)>
Public Structure TSecurityName
<MarshalAs(UnmanagedType.ByValTStr,sizeconst:=32)>
Public Name As String
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)>
Public Structure TUser
...
<MarshalAs(UnmanagedType.ByValArray, sizeconst:=10)>
Public Security() As TSecurityName
...
End Structure
I guess I am wondering why isn't the Security array "assignment" done
automatically by the marshalling? I can't I just use this simple
like so:
DIM u as TUser
u.security(0) = "Normal"
without any extra coding?
Thanks
DIM u as TUser
'---------- Why is this necessary?
Dim s(10) as TSecurityName
u.security = s
'----------
in order to do assignments like so?
u.security(0) = "Normal"
u.security(1) = "Extra"
Background:
I have c structures that in VB, it looks like this:
Type TUser
...
Security(1 To 10) As String * 32
...
End type
So the Tuser structure has a field Security which is array of 10 of
asciiz string of length 32.
In VB.NET, the structures I have is
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)>
Public Structure TSecurityName
<MarshalAs(UnmanagedType.ByValTStr,sizeconst:=32)>
Public Name As String
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)>
Public Structure TUser
...
<MarshalAs(UnmanagedType.ByValArray, sizeconst:=10)>
Public Security() As TSecurityName
...
End Structure
I guess I am wondering why isn't the Security array "assignment" done
automatically by the marshalling? I can't I just use this simple
like so:
DIM u as TUser
u.security(0) = "Normal"
without any extra coding?
Thanks