繁体   English   中英

在C#中的控制台应用程序中使用的信息如何在消息框中写入相同的信息

[英]Information that used in console application in c# how can i write same info in message box

大家好,我的问题很容易认识人,但我不知道。 问题是代码中的这个

object value = vr.ReadTypedValue();
Console.WriteLine("{0}({1},{2}):{3}", vr.NodeType, vr.Name, value.GetType().Name, value);

我想将vr.NodeType,vr.Name,value.GetType()。Name信息写入MessageBox.Show在其中。我该怎么办或如何修改此代码来解决我的问题

在控制台应用程序中:

添加

System.Windows.Forms.dll //Ty Alex

到您的项目并添加winforms代码。

在winforms =

MessageBox.Show(string.Format("{0}({1},{2}):{3}", 
               vr.NodeType, 
               vr.Name, 
               value.GetType().Name, 
               value));

消息框代码

MessageBox.Show("this shows a messagebox");

格式码

string.Format("This line formats a {0} with the given {1}","string", "params");

格式化讯息

string message = String.Format("{0}({1},{2}):{3}", 
                              vr.NodeType, vr.Name, value.GetType().Name, value);

并在MessageBox显示它:

MessageBox.Show(message);
object value = vr.ReadTypedValue();
string message = string.Format("{0}({1},{2}):{3}", vr.NodeType, vr.Name, value.GetType().Name, value);
System.Windows.Form.MessageBox.Show(message);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM