Netduino home hardware projects downloads community

Jump to content


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

byte convert


Best Answer Chris Walker, 01 April 2015 - 08:24 PM

Hi Zoro,

You can convert bytes to a character array like this:

char[] charArray = System.Text.Encoding.UTF8.GetChars(byteArray);
And you can convert a character array to a string like this:
string s = new string(charArray);
And you can convert a string to a double-precision float like this:
double d = double.Parse(s);
Does that help get you on the right path?

Chris Go to the full post


  • Please log in to reply
2 replies to this topic

#1 kalio20

kalio20

    Member

  • Members
  • PipPip
  • 22 posts

Posted 01 April 2015 - 03:53 PM

Hi,

 

my Problem is, i am trying to receive data via the serial Port, and i got no Problems with that, but the dat i receive i wanna work with, but I cant convert the received data form byte to string or to float. Is there any way this is possible in a fast and easy way like StringToByteArray?

Thanks in advance!

 

Greets

 

Zoro



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 01 April 2015 - 08:24 PM   Best Answer

Hi Zoro,

You can convert bytes to a character array like this:
char[] charArray = System.Text.Encoding.UTF8.GetChars(byteArray);
And you can convert a character array to a string like this:
string s = new string(charArray);
And you can convert a string to a double-precision float like this:
double d = double.Parse(s);
Does that help get you on the right path?

Chris

#3 kalio20

kalio20

    Member

  • Members
  • PipPip
  • 22 posts

Posted 09 April 2015 - 09:22 AM

Thx, thats exactly what i was looking for.

 

zoro






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.