问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Srr110uLib;
using Srr1100U;
namespace WpfApplication1
{
public partial class MainWindow : Window
{
SrrReader uhf = new SrrReader ("com8");
private string cc2;
public MainWindow ()
{
InitializeComponent ();
}
private void button_Click (object sender, RoutedEventArgs e)
{
/* SsuControl ssr = new SsuControl ();
ssr.Init ("com8");
byte[] cc=null;*/
uhf.ConnDevice ();
uhf.Read (c);
}
void c (string i)
{
this.Dispatcher.Invoke (() => { listBox.Items.Add (i); });
uhf.CloseDevice ();
}
private void button1_Click (object sender, RoutedEventArgs e)
{
SsuControl cc = new SsuControl ();
cc.Init ("com8");
byte[] a = cc.ReadDate ();
cc.WriteDate (a);
foreach (byte i in a)
textBox.Text += i.ToString ("X2");
cc.Close ();
}
private void textBox1_TextChanged (object sender, TextChangedEventArgs e)
{
}
private void button2_Click (object sender, RoutedEventArgs e)
{
SsuControl aa = new SsuControl ();
aa.Init ("com8");
/*byte[] b = {“”原本是在这里输入0x01这些“” };*/
/*string cc = textBox1.Text.ToString ();
cc2 = "00000000";
cc = cc2.Substring (0, 8 - cc2.Length) + cc;
byte[] b = System.Text.Encoding.Default.GetBytes (cc);这里是从网上摘抄的*/
aa.WriteDate (b);
aa.Close();
}
private void textBox_TextChanged (object sender, TextChangedEventArgs e)
{
}
}
}
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果
byte[] b = {原本是在这里输入0x01这些“};,然后读出来,现在我想启动之后,在textbox里面写,然后读写出来,怎么弄各位大咖