January 9th, 2009, 10:56 AM
ArrayList: Type casting error with ArrayList Objects
I created one ArrayList
ArrayList^ myAL = gcnew ArrayList;
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
Obviously I must need explicit casting, I have applied explicit casting in many ways Like
String ^ one=myAL->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.
January 10th, 2009, 08:25 PM
Re: ArrayList: Type casting error with ArrayList Objects
You should be using the generic list class instead of ArrayList for just about everything now : ArrayList has been included in .NET 2.0 for backwards compatibility with .NET 1.1.
using namespace System::Collections::Generic;
List<System::String ^> ^list = gcnew List<System::String ^>;
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!