2010-02-19 6 views
1

je la méthode suivante:fonction A BUILTIN Convertir octet en chaîne

public static string ByteToString(byte[] Bytes, int Length) 
    { 
     Debug.Assert(Length <= Bytes.GetLength(0)); 
     StringBuilder str = new StringBuilder(); 

     for (int i = 0; i < Length; i++) 
     { 
      str.Append((char) Bytes[i]); 
     } 

     return str.ToString(); 
    } 

Y at-il une fonction builtin pour cela? BitConverter.ToString() ne donne pas le même résultat que ci-dessus

Répondre

2
string myString = Encoding.ASCII.GetString(bytes); 

il y a aussi une surcharge qui prend l'index, et compter.

Questions connexes