【 解 説 】
stringをByte配列にするにはEncodingクラスを使用します。
以下のコードでは、日本語のstringを日本語Windowsで標準で使われているMS932(MicrosoftのShiftJIS)というByteコードに変換します。
【 例 文 】
1 2 |
string str = "日本語:マイクロソフトのShiftJIS"; byte [] bytesData = System.Text.Encoding.GetEncoding(932).GetBytes(str); |
■お薦め参考関連資料
Microsoft、Visual Studio、Visual Basic、Visual C#、Windows Vista、Windows Server、SQL Server、Visual C++、Visual Web Developerは、米国 Microsoft Corporationの米国及びその他の国における登録商標または商標です。