' VB.NET to convert a string to a byte array
Public Shared Function StrToByteArray(str As String) As Byte()
   Dim encoding As New System.Text.UTF8Encoding()
   Return encoding.GetBytes(str)
End Function 'StrToByteArray

// C# to convert a string to a byte array.
public static byte[] StrToByteArray(string str)
{
    System.Text.UTF8Encoding  encoding=new System.Text.UTF8Encoding();
    return encoding.GetBytes(str);
}

' VB.NET to convert a byte array to a string:
Dim dBytes As Byte() = ...
Dim str As String
Dim enc As New System.Text.UTF8Encoding()
str = enc.GetString(dBytes)

// C# to convert a byte array to a string.
byte [] dBytes = ...
string str;
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
str = enc.GetString(dBytes);

@ http://www.chilkatsoft.com/faq/dotnetstrtobytes.html

'020. Prigraming > 01. C#' 카테고리의 다른 글

[C#] 로컬 IP 구하기  (0) 2011.12.28
[C#] Winform에 외부폰트 적용하기  (0) 2011.10.19
[C#] Hex To String  (0) 2011.07.14
[C#] 프로세스가 살아있다.  (0) 2011.07.01
[C#] 2진수변환  (2) 2011.05.23

WRITTEN BY
테네시왈츠
항상 겸손하게 항상 새롭게 항상 진실하게

,