从字符串获取字符(C#窗口应用程序) [英] get character from string(c# window application)

查看:99
本文介绍了从字符串获取字符(C#窗口应用程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了串口数据接收软件.
假设我有像这样的数据,但是每次都不一样.每次获得不同的数据时,以下都是数据示例.

I developed serial port data receiving software.
Suppose I have data like this data, but it is not same every time. Every time I get different data, following is an example of data.

FF FF FF FF 82 00 01 02 03 04 00 05 01 02 03 04 05 ee ed


我想这样破坏数据:


I would like to break the data like this:

FF FF FF FF 
82 
00 01 02 03 04 
00 
05 
01 02 03 04 05
ee
ed


推荐答案

您将必须对其进行处理并加以解决!抱歉,但是没有为此功能的.NET功能,我必须对为什么在这些位置处中断进行假设:即序列可以,但在相同的运行结束时中断或增加. />
我这样做的方法是将字符串转换为字节流,然后将其中断,因为这样可以更轻松地确定序列的开始和结束位置.
第一部分非常简单:
You will have to process it and work it out! Sorry, but there is no .NET function for this, and I would have to make assumption about why you are breaking in those places: i.e. sequences are ok, but break at the end of a run of the same, or increasing.

The way I would do it, is to convert the string into a byte stream, then break that because it will be easier to work out where sequences start and end.
The first part is very simple:
string s = "FF FF FF FF 82 00 01 02 03 04 00 05 01 02 03 04 05 ee ed";
byte[] bytes = SoapHexBinary.Parse(s).Value;


这篇关于从字符串获取字符(C#窗口应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆