Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
C#
static System::String^ str;


I've tried to declare this variable but it gives me following error ,so plz suggest me how to get rid of this error

VB
error C3145: 'str' : global or static variable may not have managed type 'System::String ^'  Mof
Posted
Updated 23-Mar-11 12:05pm
v4
Comments
TweakBird 23-Mar-11 9:14am    
Please choose suitable Tags for your question. In title, you asked about 'Windows Form Application' but in tags you added ASP.Net. Please use 'Improve question' option to change tags.
Sergey Alexandrovich Kryukov 23-Mar-11 18:07pm    
Please tag a Question correctly. Failure to do so cause reading the post by wrong people and not reading by right people which prevents getting the Answer.
I fixed the tags for you.
--SA
Sergey Alexandrovich Kryukov 23-Mar-11 18:16pm    
I up-voted this Answer a bit to compensate some frustration: Microsoft error message betray you. My Answer explains the problem.
--SA

1 solution

Unfortunately, the problem is misleading error message. Here is how it works in real life:

You will have this error message is you try to put your declaration as 1) a declaration outside any class as in C++, 2) as a stack (local) variable.

Your declaration will be absolutely correct, if you put it as a class member.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900