I have a problem to re declare a List<String^>.

The first line compiles fine but I get this error on the second line:
'operator =' function is unavailable in 'System::Collections::Generic::List<T>'

I dont know what could be wrong here ?

List<String^> Lines = gcnew List<String^>();
Lines = gcnew List<String^>();
List<String^> Lines = gcnew List<String^>();

Declares an object not a handle and initialises it to an empty list that you gcnew to. However since it is an object and not a handle when you try to assign to it you get an operator= unavailable error because the class List does not implement operator=

If you want to be able to assign new allocated lists to the variable declar it as a handle

List<String^>^ Lines = gcnew List<String^>();
Lines = gcnew List<String^>();

Yes, okay.. then I understand.

I am thankful for your help.

Regards.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.