日期:2014-05-18  浏览次数:20494 次

StringWriter 和StringBuilder 什么关系?
StringWriter 和StringBuilder 什么关系?
看了msdn依然的不明白

------解决方案--------------------
using System;
using System.IO;
using System.Text;
 
class StrWriter
{
static void Main()
{
StringBuilder strBuilder = 
new StringBuilder("file path characters are: ");
StringWriter strWriter = new StringWriter(strBuilder);
 
strWriter.Write(
Path.InvalidPathChars, 0, Path.InvalidPathChars.Length);
 
strWriter.Close();
 
// Since the StringWriter is closed, an exception will 
// be thrown if the Write method is called. However, 
// the StringBuilder can still manipulate the string.
strBuilder.Insert(0, "Invalid ");
Console.WriteLine(strWriter.ToString());
}
}

------解决方案--------------------
stringwriter用来操作stringbuilder
好比 streamwriter 和 stream