PC Review


Reply
Thread Tools Rate Thread

char[] and byte[] to string

 
 
Ohad
Guest
Posts: n/a
 
      4th Jan 2005
Hi,

I have (in c#):

byte b = new byte[12];
char c = new char[12];
string s;

How do I make s contain the data in b and c?
Please cc to my mailbox: (E-Mail Removed)

Thanks a lot,
Ohad.


 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      4th Jan 2005

>byte b = new byte[12];
>char c = new char[12];
>string s;
>
>How do I make s contain the data in b and c?


s = new string(c);

For b, use the appropriate Encoding class from the System.Text
namespace.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to convert a char array(byte[]) to a string variable? David Microsoft C# .NET 3 17th Mar 2006 02:27 AM
how can i pass char* or string to byte*[] in C# =?Utf-8?B?55+l5piT6KGM6Zq+?= Microsoft C# .NET 2 23rd Nov 2004 09:19 AM
Convert String or char[] to byte[] Marius Cabas Microsoft C# .NET 2 12th Nov 2004 01:13 PM
multi byte char * to csharp string caviar Microsoft C# .NET 2 20th Oct 2003 03:09 PM
Re: How to convert a char of a string to single-byte character Michael Giagnocavo [MVP] Microsoft Dot NET Framework 6 23rd Jul 2003 03:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:51 PM.