3

重複の可能性:
Java の getBytes() と C# の同等物

Java の場合:

String s="abcde"; 
byte bar[] = s.getBytes();

C# の場合:

for (int i = 0; i < s.Length; i++)
{
    bar[i] = Convert.ToByte(s.Substring(i, 1)); 
}

Java の例 getBytes を使用して C# コードを変換しました。しかし、上記の C# コードは機能しません。

4

1 に答える 1

5

Encoding.GetBytes

http://msdn.microsoft.com/en-us/library/system.text.encoding.getbytes.aspx

byte[] bytes = Encoding.ASCII.GetBytes("Sweet!");
于 2012-04-30T03:54:26.537 に答える