[C#]StringWriter实现的一个功能
来源:互联网 发布:js 数组 concat 编辑:程序博客网 时间:2024/05/16 01:17
如何用一组双倍间距的句子创建一个连续的段落,然后将该段落重新转换为原来的文本:
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());
}
}
- [C#]StringWriter实现的一个功能
- StringWriter实现的一个功能
- ? StringWriter
- 实现TreeView的一个功能
- 想实现的一个功能
- 利用linux下的c语言编程来简单的实现一个shell功能实现!
- Ctrl+C的功能实现
- 【C】模仿 qsort 的功能实现一个通用的冒泡排序
- C#中StringReader和StringWriter的使用
- java中StringReader和StringWriter的讲解
- String,StringBuffer,StringBuilder,StringWriter的效率差
- 关于StringWriter与FileWriter的换行
- 用c语言实现一个strcat函数功能相同的函数
- C/C++之用两个栈实现一个队列的功能
- 用C语言写一个数组,实现类似JAVA语言中ArrayList的功能
- C语言连接到数据库实现一个具有简单的client端功能
- C语言实现一个长字符串中去除多次出现短字符串的功能
- 【c语言】写一个宏定义,实现的功能是将一个int型的数的奇偶位互换
- 季琦:VC青睐的“攻城略地者”
- oracle 导入/导出
- GridView/DataList无数据时仍然显示表头
- 又有新东西可以尝试了!
- AJAX在PHP中的简单使用
- [C#]StringWriter实现的一个功能
- windows下安装ruby on rails
- 怎样选择涂料 ?
- php和ajax结合实现登录
- vb实现系统托盘控件下载
- 用js对table数据排序
- 测试一下我下的httpwatch
- MS Jet SQL for Access 2000中级篇(转)
- DirectSound