473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

byte [] array to string , and string to byte [] array

ok i want to take a byte array

byte [] buffer = ASCIIEncoding.ASCII.GetBytes("hello there");

now yes we turned it into a byte[],
but now i want to write the represent to contents of the byte array in a file , and not the string they represent

NOT !! THIS !=========================
String hello_str = ASCIIEncoding.ASCII.getString(buffer) ;
================================================== ======

the byte array contents are 104,101,108,108,111,32,116,104,101,114,101

i am looking for a way to write the bytes value to a file
and not , and not the carcters those value represent .
Jan 22 '11 #1
3 2400
Expand|Select|Wrap|Line Numbers
  1. string resultStr=null;
  2. foreach(byte c in buffer )
  3. {
  4.    result+=c.ToString()+",";
  5. }
  6. if(result!=null)
  7. {
  8.    result=result.Substring(0, result.Length - 1);
  9. }
using for loop to get the byte array
Jan 22 '11 #2
horace1
1,510 Expert 1GB
what about something like
Expand|Select|Wrap|Line Numbers
  1.     for (int i = 0; i < 11; i++)
  2.        Console.Write(buffer[i]+",");
  3.  
Jan 22 '11 #3
10x
didnt think about that...
Jan 23 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Russell Mangel | last post by:
// Need help converting String to Byte // How do I get this String in a Byte Array String strBytes = "FFD9FFD8"; // Like this... Byte Bytes = {0xFF, 0xD9, 0xFF, 0xD8}; // This is no good,...
11
by: Dan C | last post by:
Is there a routine in c# that will transform a string ie"Hello Mom" into a Byte array. I have found char cTmp = pString.ToCharArray(); But I have not been able to figure out how to convert a...
4
by: Prabhu | last post by:
Hi, We are having problem in converting a byte array to string, The byte array has char(174), char(175), char(240), char(242) and char(247) as delimiters for the message. when we use...
6
by: Ricardo Quintanilla | last post by:
i have a code that sends data to a socket listening over as400 platform, the socket responds to me as a "byte array". then i need to convert the "byte array" into a string. the problem is that...
15
by: Kueishiong Tu | last post by:
How do I convert a Byte array (unsigned char managed) to a char array(unmanaged) with wide character taken into account?
5
by: Terry Olsen | last post by:
Looking for info on how to convert a byte array to a string, and string to byte array. Thanks.
4
by: ThunderMusic | last post by:
Hi, I have to go from Byte() to String, do some processing then reconvert the String to byte() but using ascii format, not unicode. I currently use a stream to write the char()...
3
by: David | last post by:
Hi, how to convert a char array(byte) to a string variable? byte buffer; string strTest; /*the blow codes all get type of 'buffer': System.Byte! strTest = buffer.ToString() strTest =...
16
by: Hugh Janus | last post by:
Hi all, I am using the below functions in order to convert strings to bytes and vice versa. I totally ans shamefully stole these functions from this group btw! Anyway, they work great but as...
12
by: Peter | last post by:
Trying to convert string to byte array. the following code returns byte array of {107, 62, 194, 139, 64} how can I convert this string to a byte array of {107, 62, 139, 65} ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.