0

这是写好的代码,

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

我已将 double=result1 声明为全局变量。

在标识符'result1'之前出现错误“错误C2146:语法错误:缺少')'”,那么我将如何解决这个问题?

是否需要以及如何将双精度转换为字符串?

谢谢大家。

4

1 回答 1

1

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

MessageBox::Show(
    String::Format("Time Ratio = {0}", result1),
    "Screening Result",
    MessageBoxButtons::OK, MessageBoxIcon::Information);
于 2013-05-13T05:31:47.297 回答