How to add CString and Integer to AraryList?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: How to add CString and Integer to AraryList?

Hybrid View

  1. #1
    Join Date
    Jan 2007
    Posts
    5

    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!

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,583

    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.

  3. #3
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,021

    Re: How to add CString and Integer to AraryList?

    Quote Originally Posted by Eri523 View Post

    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 View Post
    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.
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center