C++ cli 如何在messagebox上显示全局变量?

C++ cli 如何在messagebox上显示全局变量?,c++-cli,messagebox,C++ Cli,Messagebox,这是书面代码 void horizontal_calculate() { String ^aa = filenames[0]; std::string file1(marshal_as<std::string>(aa)); String ^bb = filenames[1]; std::string file2(marshal_as<std::string>(bb)); double Result3=horizontal_read

这是书面代码

void horizontal_calculate()
{
    String ^aa = filenames[0];
    std::string file1(marshal_as<std::string>(aa));
    String ^bb = filenames[1];
    std::string file2(marshal_as<std::string>(bb));

    double Result3=horizontal_read(file1);
    double Result4=horizontal_read(file2);
    double result=Result3/Result4;
    result1=result;
    System::Diagnostics::Debug::WriteLine("{0}",result);
}

private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {


             for (int i = 0; i < filenames->Length; i++)
                 System::Diagnostics::Debug::WriteLine(filenames[i]);

             semicircle();
             horizontal_calculate();
             oblique();


             MessageBox::Show("Time Ratio = "result1"","Screening Result",MessageBoxButtons::OK, MessageBoxIcon::Information);
         } 
void horizontal_calculate()
{
字符串^aa=文件名[0];
std::字符串文件1(封送(aa));
字符串^bb=文件名[1];
std::字符串文件2(封送(bb));
double Result3=水平读取(文件1);
double Result4=水平读取(文件2);
双结果=结果3/结果4;
结果1=结果;
系统::诊断::调试::写线(“{0}”,结果);
}
私有:系统::无效按钮4_单击(系统::对象^sender,系统::事件参数^e){
对于(inti=0;iLength;i++)
系统::诊断::调试::写线(文件名[i]);
半圆();
水平_计算();
斜的();
MessageBox::Show(“时间比率=“结果1”,“筛选结果”,MessageBox按钮::确定,MessageBox图标::信息);
} 
我已经声明double=result1为全局变量

在标识符'result1'之前出现了一个错误“error C2146:syntax error:missing'),那么我该如何解决这个问题呢

需要它吗?如何将double转换为string


谢谢大家。

如果问题出现在MessageBox行中,请按以下方式编写:

MessageBox::Show(
    String::Format("Time Ratio = {0}", result1),
    "Screening Result",
    MessageBoxButtons::OK, MessageBoxIcon::Information);

您必须对double.Show result1声明进行字符串化。显示C2146的线是什么?