I alreay did using loop as below
for ( int i =0; i%26lt; mybytearray.Length ; i++)
message = message + (char)mybytearray[i];
in which mybytearray is byte array
and message is string;
but dut to this spead is slows down.
plz help me.
How to convert byte array to string without using any loop ? .net c#?
Try The following Code:
byte [] arrBytes = new byte[10];
System.Text.Encoding.ASCII.GetString(a...
Also you can visit the Link:
http://geekswithblogs.net/timh/archive/2...
I hope this solves your Problem and is Good enough for being the Best Answer ;)
Reply:Thanks Report It
Reply:Thank s a lot. Report It
Reply:Will this help
' 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.ASCIIEncoding()
Return encoding.GetBytes(str)
End Function 'StrToByteArray
// C# to convert a string to a byte array.
public static byte[] StrToByteArray(string str)
{
System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding();
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.ASCIIEncoding()
str = enc.GetString(dBytes)
// C# to convert a byte array to a string.
byte [] dBytes = ...
string str;
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
str = enc.GetString(dBytes);
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment