(C#)将console.app代码迁移到Windows窗体 [英] (C#) migrate console.app code to windows form

查看:240
本文介绍了(C#)将console.app代码迁移到Windows窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将此控制台代码转换为WInForms代码。此代码用于接收数据的HexDump格式。我试图将Console.WriteLine(Hex.Dump(example))转换为textBox4.Text(Hex.Dump(示例))不知道它是否正确,仍然在努力转换console.OUtputEncoding< br $> b $ b

我尝试过:



i need to convert this console code to WInForms code. This code for HexDump format of recevieng data. I tried to convert "Console.WriteLine(Hex.Dump(example))" to "textBox4.Text (Hex.Dump(example))" Dont know is it correct or not, and still struggle with converting "console. OUtputEncoding"

What I have tried:

Console.OutputEncoding = Encoding.GetEncoding(1252);
 byte[] example = Enumerable.Range(0, 256).Select(x => (byte)x).ToArray();
 Console.WriteLine(Hex.Dump(example));

推荐答案

嗯...你所做的只是将一个字符串写入控制台。这是对WriteLine的函数调用,你传递了你想写的内容。



要在TextBox中做同样的事情,那就是设置TextBox的Text属性。

Ummm... All you're doing is writing a string to the console. That's a function call to WriteLine and you pass in what you want to write.

To do the same thing in a TextBox, that's setting the Text property of the TextBox.
textBox4.Text = Hex.Dump(example);


这篇关于(C#)将console.app代码迁移到Windows窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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