using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace TestASCIIEncoding
{
    class Program
    {
        
        
                     static void Main(string[] args)
        {
           
            string mystr = "I Like Pie";
            ASCIIEncoding ascii= new ASCIIEncoding();
            Byte[] mybuf = new byte[]{(byte) ascii.GetByteCount(mystr)};
            int MyLenght = ascii.GetCharCount(mybuf, 0, mybuf.Length);
            Char[] mychar = new char[MyLenght];
            ascii.GetChars(mybuf,0,mybuf.Length,mychar,0);            
           
            Console.WriteLine(mychar);
            Console.ReadLine();
            
            
        }
    }
}
请问为什么,我输出mychar的时候控制台程序什么都没显示呢?也不报错,就是空白的。
如果显示不出来应该报错的啊,很郁闷啊。纠结了
是我的程序的转换有问题么?
请各位大虾刚我看一看啊,谢谢了

解决方案 »

  1.   

    ascii.GetByteCount
    ascii.GetBytesCount
      

  2.   

     string mystr = "I Like Pie";
                ASCIIEncoding ascii = new ASCIIEncoding();
                 
                Byte[] mybuf =ascii.GetBytes(mystr) ;            foreach (int item in mybuf)
                {
                    Console.WriteLine(item.ToString("x"));
                }
                Console.ReadLine();不知道对不对,你不知道你想表达神马
      

  3.   

    ascii.GetByteCount,写这些方法时为防止出错,可以写ascii.点后自然会出现相应方法!