473,570 Members | 2,856 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Generic list from C++ to C#

Hi,

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

using Collections::Ge neric::List;
namespace A2M { namespace LipIntrospectio n {
public ref class BaseClassInfo
{
...
};

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

The problem is that when "BaseClasse s" 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<BaseClassI nfo>
in C#. Out of curiosity, I compared the types of the list in C# and C++
and I got the following:

"System.Collect ions.Generic.Li st`1[[A2M.LipIntrospe ction.BaseClass Info,
LipIntrospectio n, Version=1.0.219 6.29053, Culture=neutral ,
PublicKeyToken= null]]"

"System.Collect ions.Generic.Li st`1[[A2M.LipIntrospe ction.BaseClass Info,
LipIntrospectio n, Version=1.0.219 6.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
2 5465

"Nicolas Fleury" <ni******@yahoo .com_remove_the _> wrote in message
news:%d******** ************@ne ws20.bellglobal .com...
Hi,

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

using Collections::Ge neric::List;
namespace A2M { namespace LipIntrospectio n {
public ref class BaseClassInfo
{
...
};

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

The problem is that when "BaseClasse s" 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<BaseClassI nfo> in
C#. Out of curiosity, I compared the types of the list in C# and C++ and
I got the following:

"System.Collect ions.Generic.Li st`1[[A2M.LipIntrospe ction.BaseClass Info,
LipIntrospectio n, Version=1.0.219 6.29053, Culture=neutral ,
PublicKeyToken= null]]"

"System.Collect ions.Generic.Li st`1[[A2M.LipIntrospe ction.BaseClass Info,
LipIntrospectio n, Version=1.0.219 6.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<BaseClassI nfo^> BaseClasses;

should be

List<BaseClassI nfo^> ^BaseClasses;

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

Willy.

Jan 5 '06 #2
Willy Denoyette [MVP] wrote:
List<BaseClassI nfo^> BaseClasses;

should be

List<BaseClassI nfo^> ^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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
15157
by: Abhi | last post by:
In the following hypothetical example I want to build a generic list of unique string items. How should I implement the pred function so that it returns true/false if target string exists in the generic list...is not clear to me. Any suggestions? System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();...
8
1821
by: JAL | last post by:
Here is my first attempt at a deterministic collection using Generics, apologies for C#. I will try to convert to C++/cli. using System; using System.Collections.Generic; using System.Text; namespace DeterminedGenericCollection { // I got tired of copy and pasting IDisposable
0
6834
by: Wiktor Zychla [C# MVP] | last post by:
We do have generic classes, methods and delegates. My question is: what reason prevents us from having generic properties and indexers? // impossible public List<T> GetList<T> { get { ... }
0
5919
by: crazyone | last post by:
I've got a gaming framework i'm building and i want to save myself the trouble of reading and writting the complete game data to a custom file and load/save it to an XML file but i'm getting problem serializing my stuff to XML when it comes to collections. I'm currently using .net2 with generic lists to prevent users putting all sorts of...
3
2252
by: Seth Gecko | last post by:
Hi I am working with generic lists of various objects and a control dealing with these lists. For instance: A parent form holds: dim Walls as List(Of wall) dim Segments as List(Of segment) The parent form have a custom control, which have a public sub looking
4
7558
by: =?Utf-8?B?QkogU2FmZGll?= | last post by:
We have a class that has a public property that is of type List<T>. FXCop generates a DoNotExposeGenericLists error, indicating "System.Collections.Generic.List<Tis a generic collection designed for performance not inheritance and, therefore, does not contain any virtual members. The following generic collections are designed for...
1
2775
by: Suds | last post by:
Hi, I'm having an issue with invoking a Generic method that takes Generic Arguments. My method signature is public void GenericMethodWithGenericArguments<E, V>(List<EtheFirstList, List<VtheSecondList); I pass the name of the method, the arguments for the "GenericMethodWithGenericArguments" to another method, which is supposed to invoke...
13
3804
by: rkausch | last post by:
Hello everyone, I'm writing because I'm frustrated with the implementation of C#'s generics, and need a workaround. I come from a Java background, and am currently writing a portion of an application that needs implementations in both Java and C#. I have the Java side done, and it works fantastic, and the C# side is nearly there. The...
5
3630
by: Jon Slaughter | last post by:
I have some code like if (val.GetType().Name == typeof(List<>).Name) { } which lets me determine if val is a generic list(I've already taken care of the non-generic part but I'd rather be able to compare them like if (val is List<>) but this obviously doesn't work. (and I can't code it for every
2
4169
by: SimonDotException | last post by:
I am trying to use reflection in a property of a base type to inspect the properties of an instance of a type which is derived from that base type, when the properties can themselves be instances of types derived from that base type, or arrays or generic collections of instances of types derived from that base type. All is well until I come to...
0
7633
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7944
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8149
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5523
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5247
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3681
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3671
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1238
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
971
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.