Saturday, December 29, 2007

C#: Convert byte array to string

public string ConvertByteArrayToString(byte[] input)
{
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
return enc.GetString(input);
}

9 comments:

  1. is there a size limitation on the byte array?

    Thanks,
    LUN

    ReplyDelete
  2. i mean for this to work, is there a size limitation...

    -LUN

    ReplyDelete
  3. Yes of course there is a size limitation involved whenever you are dealing with memory. You have to intelligently use the function keeping available memory in mind. I just do not know what the limit is off hand. Hope this helps.

    ReplyDelete
  4. Is there a way to convert a rtf to html in c#...
    I dont want to use any third party tool or third party convertor...I want it od from c# coding only..PLease help

    ReplyDelete
  5. This is great, any idea of how to display the byte hex string like:

    2101000EF0745C9...

    ReplyDelete
  6. it is giving maximum length error to me..

    ReplyDelete
  7. my byte Array's size is byte[146842] it is not working on it...

    ReplyDelete

Please use your common sense before making a comment, and I truly appreciate your constructive criticisms.