ArrayList: Type casting error with ArrayList Objects
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: ArrayList: Type casting error with ArrayList Objects

  1. #1
    Join Date
    Oct 2008
    Posts
    16

    ArrayList: Type casting error with ArrayList Objects

    Dear All,


    I created one ArrayList

    ArrayList^ myAL = gcnew ArrayList;


    myAL->Add('#');

    myAL->Add("4");
    myAL->Add(3);
    myAL->Add(1.5);



    Finally I want to assign each type of element to String type. But I am getting Type Casting Problem, I have applied many tricks , but most of them are failed

    I need this



    String ^one=myAL[0];
    String ^two=myAL[1];
    String ^three=myAL[2];

    String ^four=myAL[3];


    Obviously I must need explicit casting, I have applied explicit casting in many ways Like


    String ^ one=myAL[0]->ToString()

    But unfortunately , instead of #, 35 are copied into the string object.

    For others I have also got surprising results.


    I only need to convert all the contents converted into string object.


    Please Suggest me how can I do this , better if you write a line of casting for me.



    Thanks


    Regards

    Aijaz Soomro.

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,352

    Re: ArrayList: Type casting error with ArrayList Objects

    I am sorrx, but you've posted this question in the wrong Forum.
    Ask it in Managed C++ and C++/CLI
    Victor Nijegorodov

  3. #3
    Join Date
    Mar 2002
    Location
    NY, USA
    Posts
    12,097

    Re: ArrayList: Type casting error with ArrayList Objects

    Quote Originally Posted by VictorN View Post
    I am sorrx, but you've posted this question in the wrong Forum.
    Ask it in Managed C++ and C++/CLI
    To add to that...please contact a moderator and ask that the thread be MOVED; do NOT create a new (duplicate) thread.

    Thanx!
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009
    In theory, there is no difference between theory and paractice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

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