VS2005 的SerialPort控件使用问题
unsigned char buff[1];
if(serialPort1->IsOpen)
{
serialPort1->Close();
}
if(!serialPort1->IsOpen)
{
serialPort1->Open();
}
serialPort1->Write(S"1");
serialPort1->Read(buff,0,1);
serialPort1->Close();
“unsigned char [1]”转换为“unsigned char __gc[]”
总是出现这种错误,
另外write函数只能写字符串吗?能否写成char类型的。 --------------------编程问答-------------------- byte[] bytesData=new byte[1];
我想把write要写的字符定义成如上格式,但出现下面的错误。
error C2143: 语法错误 : 缺少“;”(在“[”的前面)
error C3409: 不允许空属性块
error C2146: 语法错误 : 缺少“;”(在标识符“bytesData”的前面)
error C2065: “bytesData”: 未声明的标识符 --------------------编程问答-------------------- 弄明白了。
我建立的工程是C++语言下的win32 application程序。
因此
C#下的
byte[] bytesData=new byte[1];
在这里是不适用的。
那么如何在我的工程环境中生成托管对象 以便适用串口读写程序呢? --------------------编程问答-------------------- 我来接分 --------------------编程问答--------------------
unsigned char xx __gc[]=new unsigned char __gc[1];
补充:.NET技术 , 组件/控件开发