c# ArraySegment

xuxubaby發表於2014-02-17
class Program
    {
        public static void Main()
        {
            string[] arr = { "a","b","c","d"};

            ArraySegment<string> arrSeg = new ArraySegment<string>(arr);
            //arrSeg.Array[2] = "e";
            arr[2] = "e";
            for (int i = arrSeg.Offset; i < (arrSeg.Offset + arrSeg.Count); i++)
            {
                Console.WriteLine("{0}-{1}-{2}", i, arrSeg.Array[i], arrSeg.Count);
            }

            byte[] b = BitConverter.GetBytes('好');
            Console.WriteLine(b.Length);

            Console.ReadKey();
        }

        private static void AddText(FileStream fs, string value)
        {
            byte[] info = new UTF8Encoding(true).GetBytes(value);
            fs.Write(info, 0, info.Length);
        }
    }