471,337 Members | 1,368 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

System.Chart[] when convert to string

Hi,

I am using a DLL file to get a function. This has one parameter which
is a pointer. To access the function I do the following:

---------------------------------------------------------------------------------------------------
[DllImport("statax.dll")]
public static extern unsafe int fnReadMeas(char* buf);

---------------------------------------------------------------------------------------------------
Later on, in a button event I call this function as follows:

---------------------------------------------------------------------------------------------------
int Valor=0;
char[] m_BufMeas=new char[256];
fixed(char* DataRead=m_BufMeas)
{
Valor=fnReadMeas(DataRead);

if(Valor==1)
{
Mylabel.Text=Convert.ToString(m_BufMeas);
break;
}
}
---------------------------------------------------------------------------------------------------
On MyLabel I get the following text "System.Chart[]".
Any tip of how to solve this problem? I should be getting several
numbers in m_BufMeas.

Thanks in advance for your help.

Axel.
Aug 27 '08 #1
1 1118
Axel,

I assume that by System.Chart[], you mean System.Char.

You can pass that array to the constructor of the String class to create
the new string. Use the overload that takes the start index and the length,
in case not all 256 characters are used from the buffer (I assume the return
value of the unmanaged function will indicate the number of characters
written).

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"jadlaxel" <ja******@yahoo.comwrote in message
news:9f**********************************@i76g2000 hsf.googlegroups.com...
Hi,

I am using a DLL file to get a function. This has one parameter which
is a pointer. To access the function I do the following:

---------------------------------------------------------------------------------------------------
[DllImport("statax.dll")]
public static extern unsafe int fnReadMeas(char* buf);

---------------------------------------------------------------------------------------------------
Later on, in a button event I call this function as follows:

---------------------------------------------------------------------------------------------------
int Valor=0;
char[] m_BufMeas=new char[256];
fixed(char* DataRead=m_BufMeas)
{
Valor=fnReadMeas(DataRead);

if(Valor==1)
{
Mylabel.Text=Convert.ToString(m_BufMeas);
break;
}
}
---------------------------------------------------------------------------------------------------
On MyLabel I get the following text "System.Chart[]".
Any tip of how to solve this problem? I should be getting several
numbers in m_BufMeas.

Thanks in advance for your help.

Axel.

Aug 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mahesh Devjibhai Dhola | last post: by
22 posts views Thread by PeteCresswell | last post: by
15 posts views Thread by Yifan | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.