0

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^>();

Edited by Lukezzz: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Lukezzz
0
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^>();
0

Yes, okay.. then I understand.

I am thankful for your help.

Regards.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.