1

Whenever I try to directly assign a String variable to another String variable I get error found no suitable conversation.
So is there a way to convert String^ pointer to a non-pointer struct String ?

I want :

System::String a = System::String('X',256);

I don't want :

System::String^ a = %System::String('X',256);
1
  • 1
    System::String is an immutable reference type. You don't get to change that, you must use the hat. If you don't like the syntax then just don't use C++/CLI, both C# and VB.NET make no distinction between value and reference types in their syntax. Commented Mar 9, 2013 at 13:18

2 Answers 2

3

No, there is not, because as Hans pointed out in a comment, System::String is immutable. You cannot assign it. You can only associate a handle with an entirely new System::String object.

BTW

System::String^ a = %System::String('X',256);

is incorrect, it should be

System::String^ a = gcnew System::String('X',256);
Sign up to request clarification or add additional context in comments.

Comments

-1

Use System::String a('X', 256);.

3 Comments

Thanks but this is not conversion, it was just an example. What if I want assign System::String a to System::String b ?
Then why don't you use b = a?
That throw error C3149: 'System::String' : cannot use this type here without a top-level '^'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.