2D arrays... 
Author Message
 2D arrays...

Hi!

I have a dll returning a pointer to a block of memory which is a single
block two dimensional
array.  Is there a way to type cast this pointer so that it would be
possible to work on values from that array? Even a type-cast to a one
dimensional array would do fine...

Thanks!
Janez



Fri, 13 May 2005 05:35:00 GMT  
 2D arrays...
Hi Janez,

Hope this helps:

In the Dll
========
        Int32[,] intArray;
        public Int32[,] MyArray()
        {
            intArray=new Int32[2,2];
            for (int i=0;i<2;i++)
            {
                for (int j=0;j<2;j++)
                {
                    intArray[i,j]=(i*100)+j;
                }
            }

            return intArray;
        }

In Client Application
=================

            Int32[,] array;
            ClassLibrary1.Class1 cls=new ClassLibrary1.Class1();
            array=cls.MyArray();
            for (int i=array.GetLowerBound(0);i<=array.GetUpperBound(0);i++)
            {
                for(int
j=array.GetLowerBound(1);j<=array.GetUpperBound(1);j++)
                {
                    Console.WriteLine(array[i,j].ToString());
                }
            }
            Console.WriteLine("GetLowerBound(0): " +
array.GetLowerBound(0));
            Console.WriteLine("GetUpperBound(0): " +
array.GetUpperBound(0));
            Console.WriteLine("GetLowerBound(1): " +
array.GetLowerBound(1));
            Console.WriteLine("GetUpperBound(1): " +
array.GetUpperBound(1));
        }

If I misunderstood your concerns, please correct me.

Thanks,

Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

Quote:

>Newsgroups: microsoft.public.dotnet.languages.CSharp
>Subject: 2D arrays...
>Lines: 12
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106

>Date: Sun, 24 Nov 2002 22:35:00 +0100
>NNTP-Posting-Host: 193.77.154.126

>X-Trace: news.siol.net 1038173804 193.77.154.126 (Sun, 24 Nov 2002
22:36:44 MET)
>NNTP-Posting-Date: Sun, 24 Nov 2002 22:36:44 MET
>Organization: Slovenija OnLine - SiOL
>Path:

cpmsftngxa06!tkmsftngp01!cppssbbsa01.microsoft.com!news-out.cwix.com!newsfee
d.cwix.com!news-hub.siol.net!news.siol.net!not-for-mail

- Show quoted text -

Quote:
>Xref: cpmsftngxa06 microsoft.public.dotnet.languages.csharp:110899
>X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

>Hi!

>I have a dll returning a pointer to a block of memory which is a single
>block two dimensional
>array.  Is there a way to type cast this pointer so that it would be
>possible to work on values from that array? Even a type-cast to a one
>dimensional array would do fine...

>Thanks!
>Janez



Sat, 14 May 2005 12:05:31 GMT  
 2D arrays...
Hi!

What I had in my mind was
a way to typecast a pointer returned
from a dll by the GetMem procedure.
(typecast a unmanaged pointer to a managed one
without copying the array.)

Thanks!
Janez.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Sun, 15 May 2005 04:15:17 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Which 2D array of 2D array addressing method?

2. 2D array of pointers to 2D arrays

3. use 1d array + macro or 2d array?

4. Multiply and Add matrices with 2d array WITHOUT ARRAY INDEXING

5. Fast array transfer with 2D arrays...?

6. Passing a 2d array from .NET to COM

7. Passing 2D arrays to functions with const.

8. passing 2d arrays by reference

9. Text Data File to 2D Array?

10. Help manipulating 2D array using (not and)

11. Help manipulating 2D array

12. Question - Dynamic 2d arrays in C

 

 
Powered by phpBB® Forum Software