如何用一组双倍间距的句子创建一个连续的段落,然后将该段落重新转换为原来的文本:
using system;
using system.io;
class stringrw
{
static void main()
{
string textreadertext = "textreader is the abstract base " +
"class of streamreader and stringreader, which read " +
"characters from streams and strings, respectively./n/n" +
"create an instance of textreader to open a text file " +
"for reading a specified range of characters, or to " +
"create a reader based on an existing stream./n/n" +
"you can also use an instance of textreader to read " +
"text from a custom backing store using the same " +
"apis you would use for a string or a stream./n/n";
console.writeline("original text:/n/n{0}", textreadertext);
string aline, aparagraph = null;
stringreader strreader = new stringreader(textreadertext);
while(true)
{
aline = strreader.readline();
if(aline != null)
{
aparagraph = aparagraph + aline + " ";
}
else
{
aparagraph = aparagraph + "/n";
break;
}
}
console.writeline("modified text:/n/n{0}", aparagraph);
int intcharacter;
char convertedcharacter;
stringwriter strwriter = new stringwriter();
strreader = new stringreader(aparagraph);
while(true)
{
intcharacter = strreader.read();
if(intcharacter == -1) break;
convertedcharacter = convert.tochar(intcharacter);
if(convertedcharacter == '.')
{
strwriter.write("./n/n");
strreader.read();
strreader.read();
}
else
{
strwriter.write(convertedcharacter);
}
}
console.writeline("/noriginal text:/n/n{0}",
strwriter.tostring());
}
}
新闻热点
疑难解答