How to add CString and Integer to AraryList?
I need to read out a file, analysis and store difference data in CSting and Int. I create an ArrayList but how can I store both CString nd Int to that ArrayList? Or how can I convert CString to String^
and so I can store them into an ArrayList?
I don't understand that ArrayList can store object but why a CString do not count as object?
Thanks so much!
Re: How to add CString and Integer to AraryList?
CString supports certain implicit conversions, so you can simply pass the CString object as the parameter to the System::String constructor. Depending on whether you're doing a Unicode or MBCS build, it will match either of two out of the three one-parameter constructor oveloads of System::String. See How to: Convert Between Various String Types, a really helpful MSDN page that, BTW, turned up right at the top of the results of a simple MSDN search for CString. ;)
Is there any specific reason why you're mixing MFC and C++/CLI?
Re: How to add CString and Integer to AraryList?
Quote:
Originally Posted by
Eri523
Is there any specific reason why you're mixing MFC and C++/CLI?
Let me guess... to get a painful headache? It's like mixing beer and wine. :)
Quote:
Originally Posted by
dynamictoys
I don't understand that ArrayList can store object but why a CString do not count as object?
CString does NOT inherit from .NET's System.Object, simply because it's NOT a .NET stuff.
Have a look at
As a general advice: do not mix them in order to avoid headaches.