Netduino home hardware projects downloads community

Jump to content

The Netduino forums have been replaced by new forums at This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.


Member Since 13 Feb 2013
Offline Last Active May 18 2013 05:09 PM

Topics I've Started

convert byte to string

30 April 2013 - 06:55 PM

so a i have a gsm cellular sheild connected to a netduino com1 and i want to read data from com1, but i have failed to convert the bytes output to string, the method:

string result =System.Text.Encoding.UTF8.GetSTring(bytes);

doesnt seem to exist in the microframe work library so i tried to use this:


        static void port_DataReceived(object sender, SerialDataReceivedEventArgs e) {
            byte[] bytes = new byte[1];
           while (port.BytesToRead > 0)
                port.Read(bytes, 0 , bytes.Length);
                //port.Write(bytes, 0, bytes.Length);
            char[] cc = Encoding.UTF8.GetChars(bytes, 0, bytes.Length);
            string s = new string(cc);
            catch(Exception ex) {
but it throws  a system.exception  and i dont why. 

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.