Re: Array of pointer in C#

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Jonathan Woodbury (jw_at_systrackinc.com)
Date: 01/28/05


Date: Fri, 28 Jan 2005 09:10:29 -0800

This MSDN article has examples for this kind of thing:

http://msdn.microsoft.com/msdnmag/issues/02/08/CQA/

I hope one of the examples helps.

- Jonathan W.

"Kathy Tran" <Kathy Tran@discussions.microsoft.com> wrote in message
news:E9E0B4C6-1DAB-446C-BA5D-55DAB4EFF3CB@microsoft.com...
> Hi Nicholas Paldino ,
> Thanks for responding my question. I am performing some of interop which
> requires an array of pointers to these structures to be taken. In my
> program
> I want to go through an array of pointer, with each element in array I
> assign
> some values in structure and then pass each element to un unmanaged code
> function
>
> [DllImport("PikaAPI.dll")]
> unsafe public static extern int PK_AUDIO_InputAddBuffer(SEventQ *pEvent);
>
> but I am very confusing and do not how to declare an array of pointer.
>
> Thank,
> Kathy Tran
>
> "Nicholas Paldino [.NET/C# MVP]" wrote:
>
>> Kathy,
>>
>> Why do you want an array of pointers. Are you performing some sort
>> of
>> interop which requires an array of pointers to these structures to be
>> taken,
>> or do you need an array of structure?
>>
>> If you wanted an array of pointers, I believe you would do:
>>
>> SEventQ **EvQ;
>>
>> However, you couldn't say "new SEventQ*", since you can't "create" a
>> pointer in that manner.
>>
>> What is it that you are trying to do?
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mvp@spam.guard.caspershouse.com
>>
>>
>>
>> "Kathy Tran" <Kathy Tran@discussions.microsoft.com> wrote in message
>> news:C4061BD4-39EE-4DDA-A28A-BE68F0AAC0DF@microsoft.com...
>> > Hi,
>> > Could you please help me how to declare an araay of pointer in C#.
>> > In my program I declared an structure
>> >
>> > public struct SEventQ
>> > {
>> > public uint uiUserData;
>> > public uint uiEvent;
>> > public uint uiParam0;
>> > public uint uiParam1;
>> > }
>> >
>> > Now I want to delare an array of pointer look likes
>> > unsafe SEventQ [] *EvQ = new SEventQ[10];
>> >
>> >
>> > Thanks,
>> >
>> > Kathy Tran
>>
>>
>>



Relevant Pages

  • Re: Differance between Array and Pointers
    ... Well, except that arrays tend to be much larger than pointers, and the ... An array is a contiguous region of memory containing N elements of M ... indexing vs. a loop). ...
    (comp.arch.embedded)
  • [RFCv2][PATCH] flexible array implementation
    ... I call it a flexible array. ... storage for pointers to the second level. ... all locking must be provided by the caller. ... make sure to pass in &ptr instead of ptr. ...
    (Linux-Kernel)
  • [RFC][PATCH] flexible array implementation v4
    ... I call it a flexible array. ... so never does an order>0 allocation. ... storage for pointers to the second level. ... all locking must be provided by the caller. ...
    (Linux-Kernel)
  • Re: [RFC][PATCH] flexible array implementation v4
    ... I call it a flexible array. ... so never does an order>0 allocation. ... storage for pointers to the second level. ... all locking must be provided by the caller. ...
    (Linux-Kernel)
  • Re: [RFCv2][PATCH] flexible array implementation
    ... I call it a flexible array. ... storage for pointers to the second level. ... all locking must be provided by the caller. ... make sure to pass in &ptr instead of ptr. ...
    (Linux-Kernel)