C# Tips


stringをByte配列にするには


stringをByte配列にするにはEncodingクラスを使用します。
以下のコードでは、日本語のstringを日本語Windowsで標準で使われているMS932(MicrosoftのShiftJIS)というByteコードに変換します。

string str = "日本語:マイクロソフトのShiftJIS";
byte [] bytesData = System.Text.Encoding.GetEncoding(932).GetBytes(str);


目次に戻る
Copyright(c) 2008 WoodenSoldier Software