简体   繁体   English

将对象转换为字符串

[英]converting object to string

I use this code for calling a matlab function in C# 我用这段代码在C#中调用matlab函数

Object b;
matlab.Feval("fun444",(int)1,out b,(double)(10));
label1.Text = b.ToString();`

it works and I could saw my answer in b using debugging mode . 它工作,我可以使用调试模式在b中看到我的答案。 I want to display his number but it returns to me : system.object[] How can I display the double I saw in the debugger? 我想显示他的号码,但它返回给我:system.object []如何显示我在调试器中看到的双精度数?

You have an array instead of a single object. 你有一个数组而不是一个对象。

You'll need to do something like this... Edit: I didn't see you were setting a textbox the first time I looked at your code. 你需要做这样的事情...编辑:我第一次看你的代码时没有看到你设置了一个文本框。

label1.Text = b[0].ToString();

matlab.Feval为您提供了一个元素的数组,您可以这样得到它:

label1.Text = ((object[])b)[0].ToString()

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

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