why i can't put struct to Generic::List

  • Thread starter Thread starter shengmin.ruan
  • Start date Start date
S

shengmin.ruan

the wrong code is:

[StructLayout(LayoutKind::Sequential)]
public ref struct OutPacket{
int index;
List<MainInfo^>^ mainInfos;
};

[StructLayout(LayoutKind::Sequential)]
public ref struct MainInfo{
String^ value1;
String^ value2;
};

----------
the error message is:
Error 1 error C2065: 'MainInfo' : undeclared identifier


please help me ,thank u
 
[StructLayout(LayoutKind::Sequential)]
public ref struct OutPacket{
int index;
List<MainInfo^>^ mainInfos;
};

[StructLayout(LayoutKind::Sequential)]
public ref struct MainInfo{
String^ value1;
String^ value2;
};

Try swapping the declarations. When you declare OutPacket, MainInfo is still
unknown because its declaration is placed after the declaration to
OutPacket.
Declaring MainInfo first takes care of that problem.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
Back
Top