PC Review


Reply
Thread Tools Rate Thread

Arrays in structs

 
 
cody
Guest
Posts: n/a
 
      16th Mar 2005
IIRC you can simply use datatype string for that. Additionally you could use
the MarshalAs attribute but Iam not sure.

"Claire" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> I need to set up an array in a struct for passing to a win32 api call .

How
> do I do this please?
> ("Name" is actually a zero terminated ascii string, so a pointer to a
> better way to do this would also be appreciated)
>
> eg
> [StructLayout(LayoutKind.Sequential)]
>
> public struct Details
>
> {
>
> public int UniqueID;
>
> public byte[] Name[43]; << wrong here, also should be ascii chars
>
> public eState Status;
>
> }
>
>



 
Reply With Quote
 
 
 
 
Claire
Guest
Posts: n/a
 
      16th Mar 2005
I need to set up an array in a struct for passing to a win32 api call . How
do I do this please?
("Name" is actually a zero terminated ascii string, so a pointer to a
better way to do this would also be appreciated)

eg
[StructLayout(LayoutKind.Sequential)]

public struct Details

{

public int UniqueID;

public byte[] Name[43]; << wrong here, also should be ascii chars

public eState Status;

}


 
Reply With Quote
 
Claire
Guest
Posts: n/a
 
      16th Mar 2005
"cody" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> IIRC you can simply use datatype string for that. Additionally you could
> use
> the MarshalAs attribute but Iam not sure.
>


thanks for answering so quickly cody but that was all gobbledegook at my
level (I just about understood the IIRC bit)
Can you give me a code snippet or link to example please


 
Reply With Quote
 
Mattias Sjögren
Guest
Posts: n/a
 
      16th Mar 2005

public struct Details
{
public int UniqueID;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=43)]
public string Name;
public eState Status;
}



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
 
Reply With Quote
 
cody
Guest
Posts: n/a
 
      16th Mar 2005
see matthias's reply.

"Claire" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> "cody" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > IIRC you can simply use datatype string for that. Additionally you could
> > use
> > the MarshalAs attribute but Iam not sure.
> >

>
> thanks for answering so quickly cody but that was all gobbledegook at my
> level (I just about understood the IIRC bit)
> Can you give me a code snippet or link to example please
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Arrays of classes or structs, which is best =?Utf-8?B?TWFjY2E=?= Microsoft C# .NET 5 27th May 2006 07:35 AM
arrays, structs, pointers, casting - help! kelli Microsoft C# .NET 4 4th Aug 2005 08:35 PM
Interfacing with an API - structs with arrays of structs. Dave A Microsoft Dot NET 1 29th Dec 2004 11:47 PM
Arrays inside of structs Ken Beauchesne Microsoft C# .NET 2 29th Oct 2004 02:11 PM
C structs containing arrays to VB Chris Tacke, eMVP Microsoft Dot NET Compact Framework 3 26th Nov 2003 02:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:57 AM.