Click here to Skip to main content
15,356,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I started developing a small test WinForms application using Visual Studio Community Edition C#. I need to use the StringBuilder class, that I have used many times before. VS could not find StringBuilder event though I had a "using System.Text;" statement. I recently updated Visual Studio to 15.7.5. This may be cause. Anybody have ideas on a fix.

What I have tried:

I tried explicit with same results --
i.e. System.Text.StringBuilder sb = new ...

I searched MSDN support and forums and found nothing pertinent.
Posted
Updated 16-Jul-18 7:01am

System.Text is built into mscorlib. It's a reference that is always there, no matter what. You can't change it or delete it, so....

Try going into your Project Properties and changing the Target Framework version to a different version higher than the one it's set for, then hit "Yes" on the dialog that comes up.

You can either leave it there or, once you compile the app one under the new version, change that back to the old version and try it again.
   
Comments
Member 10767967 16-Jul-18 13:03pm
   
Thanks Dave - you pointed me in the right direction and I fixed it by recreating the project.
I just tried and it worked,

using System.Text;

StringBuilder sb = new StringBuilder(text);
   
Comments
Member 10767967 16-Jul-18 12:38pm
   
THANK YOU -- Not surprised. It has worked many times for me. What version of Visual Studio are you running?
F-ES Sitecore 16-Jul-18 12:41pm
   
It's got nothing to do with Visual Studio, VS is just an IDE. You've probably created a ".net Core" project rather than a .net one.
Ryan Peden 16-Jul-18 12:54pm
   
I don't think that would cause it. StringBuilder is present in .NET Core and works happily for me in a .NET Core console app.
I went back and created a new "Windows Forms App (.NET Framework)" and it works.
I must have created incorrectly the first time, although I could not identify in the Project Properties.
   

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