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

时间:2014-02-03 11:41:00

标签: c# winforms console-application

大家好日子。我的问题很容易认识,但我不知道。问题在于代码

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

我想写vr.NodeType,vr.Name,value.GetType()。在其中给MessageBox.Show命名信息。我该怎么办?如何修改这段代码来解决我的问题

3 个答案:

答案 0 :(得分:1)

在控制台应用中:

添加

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");

答案 1 :(得分:1)

格式化邮件

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

并在MessageBox中显示:

MessageBox.Show(message);

答案 2 :(得分:0)

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);