-
September 26th, 2012, 12:21 PM
#1
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!
-
September 27th, 2012, 04:26 AM
#2
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?
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
September 29th, 2012, 02:05 AM
#3
Re: How to add CString and Integer to AraryList?
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.
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.
Last edited by ovidiucucu; September 29th, 2012 at 02:10 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|