国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

StringWriter實現的一個功能

2019-11-18 17:13:14
字體:
來源:轉載
供稿:網友

如何用一組雙倍間距的句子創建一個連續的段落,然后將該段落重新轉換為原來的文本:

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());
    }
}

http://jigee.VEVb.com/archive/2006/05/20/405151.html


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 洞头县| 江津市| 龙岩市| 晋江市| 红河县| 九江县| 宁海县| 晋中市| 汉寿县| 拉孜县| 玛纳斯县| 仁寿县| 榆林市| 崇礼县| 阿克苏市| 兴隆县| 临漳县| 雅江县| 健康| 明星| 贵德县| 岳普湖县| 琼海市| 松江区| 冷水江市| 盘锦市| 临桂县| 曲阳县| 广丰县| 自贡市| 黄平县| 昭苏县| 岢岚县| 金乡县| 平乡县| 玉树县| 新余市| 容城县| 独山县| 通道| 镇江市|