user1903439
user1903439

Reputation: 2001

C2228: left of '.Text' must have class/struct/union

I am receiving the mentioned error. My code is as follows:

String^ result;
result = marshal_as<String^>( fd.cFileName );
label.Text = result; // i have a label on form

Any idea. i have a guess that i need to convert String^ to string. if it is, then how can i do that

Upvotes: 0

Views: 1930

Answers (1)

David Heffernan
David Heffernan

Reputation: 612794

The error message is telling you that the symbol to the left of . must be a class struct or union. If is none of those. Instead it is a handle to a managed type.

Your code should read

label->text = result;

Upvotes: 1

Related Questions