By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,166 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,166 IT Pros & Developers. It's quick & easy.

Generic list from C++ to C#

P: n/a
Hi,

I have a field named "BaseClasses" in C++ as in the following simplified
code:

using Collections::Generic::List;
namespace A2M { namespace LipIntrospection {
public ref class BaseClassInfo
{
...
};

public ref class ClassInfo
{
public:
List<BaseClassInfo^> BaseClasses;
...
};
}}

The problem is that when "BaseClasses" is accessed in C#, I get an error
"is not supported in the language". I'm able to use the BaseClassInfo
class without problem and I'm also able to define a List<BaseClassInfo>
in C#. Out of curiosity, I compared the types of the list in C# and C++
and I got the following:

"System.Collections.Generic.List`1[[A2M.LipIntrospection.BaseClassInfo,
LipIntrospection, Version=1.0.2196.29053, Culture=neutral,
PublicKeyToken=null]]"

"System.Collections.Generic.List`1[[A2M.LipIntrospection.BaseClassInfo,
LipIntrospection, Version=1.0.2196.29233, Culture=neutral,
PublicKeyToken=null]]"

Is it possible that C++ and C# are using different versions of the
generic list?

Note that I'm pretty new to .Net and C#, so maybe I'm missing something?

Thx and regards,
Nicolas Fleury
Jan 5 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Nicolas Fleury" <ni******@yahoo.com_remove_the_> wrote in message
news:%d********************@news20.bellglobal.com. ..
Hi,

I have a field named "BaseClasses" in C++ as in the following simplified
code:

using Collections::Generic::List;
namespace A2M { namespace LipIntrospection {
public ref class BaseClassInfo
{
...
};

public ref class ClassInfo
{
public:
List<BaseClassInfo^> BaseClasses;
...
};
}}

The problem is that when "BaseClasses" is accessed in C#, I get an error
"is not supported in the language". I'm able to use the BaseClassInfo
class without problem and I'm also able to define a List<BaseClassInfo> in
C#. Out of curiosity, I compared the types of the list in C# and C++ and
I got the following:

"System.Collections.Generic.List`1[[A2M.LipIntrospection.BaseClassInfo,
LipIntrospection, Version=1.0.2196.29053, Culture=neutral,
PublicKeyToken=null]]"

"System.Collections.Generic.List`1[[A2M.LipIntrospection.BaseClassInfo,
LipIntrospection, Version=1.0.2196.29233, Culture=neutral,
PublicKeyToken=null]]"

Is it possible that C++ and C# are using different versions of the generic
list?

Note that I'm pretty new to .Net and C#, so maybe I'm missing something?

Thx and regards,
Nicolas Fleury


List<BaseClassInfo^> BaseClasses;

should be

List<BaseClassInfo^> ^BaseClasses;

C# does not support stackbased semantics, so you must declare a reference.

Willy.

Jan 5 '06 #2

P: n/a
Willy Denoyette [MVP] wrote:
List<BaseClassInfo^> BaseClasses;

should be

List<BaseClassInfo^> ^BaseClasses;

C# does not support stackbased semantics, so you must declare a reference.


Oups. Thx, stupid mistake from me; haven't notice it for this field
because the preceding field was a simple type.

Thx,
Nicolas
Jan 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.