type problems with .net types *arrgh* 
Author Message
 type problems with .net types *arrgh*

ok, in .NET you have a byte array and in C# you create it like so; Byte[]
mybyte ....

Now I have a c# dll that I'm using from mc++ and one function returns this
Byte[] type but I can't
seem to create an equivilent in mc++ ? I tried CByteArray but get a
convertion error. I will of course want to then pass the c++ eq. type back
to this function later as Byte[] ?

Craig



Tue, 14 Sep 2004 03:06:43 GMT  
 type problems with .net types *arrgh*
To declare an array Variable:

    Byte    myArray[] = new Byte[ 12 ];    // Byte is a value type
    Byte    myArray[] = { 12, 23, 32 };

    String*    myArray[] = new String*[12];
    String*    myArray[] = { S"onut", S"onutaou" };

To return an array from a function:

    Byte    Function() []
    {
        return new Byte[12];
    }

    String*    Function() []
    {
        return new String*[12];
    }

To pass an 'IN' array argument to a function

    void Function( Byte theArray[] )
    {
    }

    void Function( String* theArray[] )
    {
    }

To pass a 'REF' array argument to a function

    typedef Byte ByteArray[];
    void Function( /*REF*/ ByteArray& theArray  )
    {
        theArray = new Byte[ 123 ];
    }

    typedef String* StringArray[];
    void Function( /*REF*/ StringArray& theArray )
    {
    }

--
Anson Tsao
Visual C++ libraries team

Of course, this posting wouldn't be complete without a nice, juicy
disclaimer from our lawyers: This posting is provided "AS IS" with no
warranties, and confers no rights. You assume all risk for your use. ? 2001
Microsoft Corporation. All rights reserved.


Quote:
> ok, in .NET you have a byte array and in c# you create it like so; Byte[]
> mybyte ....

> Now I have a c# dll that I'm using from mc++ and one function returns this
> Byte[] type but I can't
> seem to create an equivilent in mc++ ? I tried CByteArray but get a
> convertion error. I will of course want to then pass the c++ eq. type back
> to this function later as Byte[] ?

> Craig



Tue, 14 Sep 2004 05:44:35 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. DLL types to .NET types?

2. C# Base Types vs. .NET Types

3. Type Casting between Base and Derived Type (Serialization of objects with Type members)

4. Variables and types of type "Type"

5. MessengerAPI type library - IDispatch enum type problem

6. type cast problem of C++ in .Net

7. Using types in a different assembly given that the type may be used or not used

8. Help with: C2392 - covariant returns types are not supported in managed types

9. <type>* : Is this a type?

10. type casting to / from pointers to incomplete data types

11. Object type cannot be converted to target type

12. using incomplete structure types as opaque types

 

 
Powered by phpBB® Forum Software