Monday, March 26, 2012

StringBuilder

Can anyone tell me why I get an error that StringBuilder not found? Am I missing a directive?

using System;
using System.IO;
namespace Formatting
{
public class MyDates
{
[STAThread]
static void Main(string[] args)
{
StringBuilder MyStringBuilder = new StringBuilder("Hello !");
MyStringBuilder.Replace('!', '?');
Console.WriteLine(MyStringBuilder);

}

}
}


ThanksThe StringBuilder is found in System.Text namespace.

You forgot to add


using System.Text;

thus the application cannot know who StringBuilder is.
Hi,

You need to put using System.Text;

thanks.

0 comments:

Post a Comment