use*_*082 1 c# wpf type-conversion
how can i convert decimal value to AScii , i have tried with
var charStrs = Convert.ToString(receivedEvent.tagData.can_Msg.data[3]) +
Convert.ToString(receivedEvent.tagData.can_Msg.data[4]) +
Convert.ToString(receivedEvent.tagData.can_Msg.data[5]) +
Convert.ToString(receivedEvent.tagData.can_Msg.data[6]) +
Convert.ToString(receivedEvent.tagData.can_Msg.data[7]);
var asStr = String.Concat(charStrs.Select(cs => (char)Int32.Parse(cs, NumberStyles.HexNumber)));
Run Code Online (Sandbox Code Playgroud)
i know that my decimal number = 56 49 50 48 48 48 53 56 50 56 and when converting it to ascii i will get 8120005828;but i get error in NumberStyles.HexNumber its seems it does not work on wpf ?
I'm not really sure what values are in data[3], etc. but with values from http://www.asciitable.com/
int[] values = { 56, 49, 50, 48, 48, 48, 53, 56, 50, 56 };
char[] chars = values.Select(x => (char)x).ToArray();
string str = new string(chars);
Console.WriteLine(str); // "8120005828"
Run Code Online (Sandbox Code Playgroud)
Part of your problem might be that those are decimal numbers, but you're trying to parse them as hex numbers.
| 归档时间: |
|
| 查看次数: |
3622 次 |
| 最近记录: |