c#之stream相关类小记

using System;
using System.IO;
class Test
{
    public static void Main()
    {
          //using写法,声明一个类对象,然后在using后面的{}中使用此类对象
          //注:using写法表示此对象仅在此范围可用,非此范围就会dispose此占用的resource
        using(StreamWriter sw=new StreamWriter("c:\\teststream.txt"))
        {
            sw.Write("1");//向stream中写东东(从外面)
            sw.WriteLine("2 and new");
            sw.WriteLine(DateTime.Now);

////write(要写入到流的char数组,char数组的起始位置,char数组的元素个数
            sw.Write(new char[] { 't','o','u','x'},0,4);
            Console.ReadKey();
        }
    }
}

附上stream类的链接:
http://msdn.microsoft.com/zh-cn/library/system.io.stream%28VS.80%29.aspx
请使用浏览器的分享功能分享到微信等