2

Possible Duplicate:
What does “Invalid managed/unmanaged type combination.” mean?

how we will code these structures(Written in C++) in C#

typedef struct tagBIRDMATRIX
{
short   n[3][3];    // array of matrix elements
}BIRDMATRIX;
Community
  • 1
  • 1
LMC008
  • 53
  • 1
  • 6

1 Answers1

7

The size should be the number of elements in your cross product.

 struct BIRDMATRIX
 {
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)]
    short[,] n;
 }
Jonathan Henson
  • 8,076
  • 3
  • 28
  • 52
  • Neat trick, I was trying to use `fixed` with good 'ol multidimensional arrays but that doesn't compile. You can however do stuff like this `fixed short n[3 * 3]` but yours truly is better. – John Leidegren Jun 01 '11 at 07:28
  • it is got error,"Error 1 Bad array declarator: To declare a managed array the rank specifier precedes the variable's identifier. To declare a fixed size buffer field, use the fixed keyword before the field type." – LMC008 Jun 01 '11 at 07:31
  • @John, yea try and stay away from fixed and pointers in C# if you can help it. They are handy in a language that doesn't treat you like a two year old, but usually a pain in the ole arse when you need them in c#. I love .NET but sometimes, I just want my pointers back. – Jonathan Henson Jun 01 '11 at 07:33
  • @LMC008 Sorry, I'll fix that. – Jonathan Henson Jun 01 '11 at 07:37
  • @LMC008 Check it now. I always mix that up. – Jonathan Henson Jun 01 '11 at 07:37
  • @LMC008 , that should work. You don't need unsafe anymore though. – Jonathan Henson Jun 01 '11 at 07:40