I have tried to delare the List Incr outside the if-statment and then inside the if-statement I declare a new instance of the List but when doing this I get a compilerror that says:


left of '.Add' must have class/struct/union

List<int>^ Incr;


if( textBox1->Text != "" )
{

	Incr = gcnew List<int>;
	//Add element
	Incr.Add(1);

}

Recommended Answers

All 2 Replies

>Incr.Add(1);
You use the arrow operator to access members of managed references:

Incr->Add(1);

Ah ofcourse, Thank you Narue.. I confused it with C#

/L

>Incr.Add(1);
You use the arrow operator to access members of managed references:

Incr->Add(1);
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.