Visual C++错误C2146
每个人, 我试图使用 C++/CLI 编译一个程序来检查我的股票,但当我将变量放入 URL 时遇到错误。有人可以帮我吗?
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
this->webBrowser1->Navigate("http://finance.yahoo.com/echarts?s="num".HK+Interactive#chart1:symbol="num".hk;range=1d;indicator=volume;charttype=line;crosshair=on;ohlcvalues=0;logscale=on;source=undefined");
}
哦,顺便说一下,这段代码来自“Windows 窗体应用程序”,变量的名称是“num”。再次强调,如果可能的话,我将不胜感激。谢谢。
everyone,
I was trying to compile a program using C++/CLI to check my stocks, but I ran into an error when I put the variable in the URL. Can anyone help me, please?
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
this->webBrowser1->Navigate("http://finance.yahoo.com/echarts?s="num".HK+Interactive#chart1:symbol="num".hk;range=1d;indicator=volume;charttype=line;crosshair=on;ohlcvalues=0;logscale=on;source=undefined");
}
Oh, and by the way, this code is from a "Windows Forms Application" and the name of the variable is "num". Again, I would appreciate any help if possible. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您没有做任何事情来构建字符串。我从来没有做过托管 C++,但我认为你不能这样做:
"http://finance.yahoo.com/echarts?s="num
并得到你想要的。在 C# 中,您可以只使用operator+:"http://finance.yahoo.com/echarts?s=" + num
,或者使用 StringBuilder 或 String.Format。我想托管 C++ 中也有类似的东西。It looks like you aren't doing anything to build the string. I've never done managed C++, but I assume you can't do this:
"http://finance.yahoo.com/echarts?s="num
and get what you want. In C#, you could just use operator+:"http://finance.yahoo.com/echarts?s=" + num
, or use StringBuilder, or String.Format. I'd imagine there's something similar in managed C++.