Error 1 Expected class, delegate, enum, interface, or struct
代码如下:
using System;
using JustinIO.cs;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace smsForCSharp
{
public partial class Form1 : Form
{
static JustinIO.CommPort ss_port = new JustinIO.CommPort();
public Form1()
{
InitializeComponent();
}
}
public bool InitCom(string m_port ,int m_boudrate)
{
ss_port.PortNum = COM1; //端口号
ss_port.dwProvSubType =PST_RS232;//端口类型
ss_port.BaudRate = 19200; //串口通信波特率
ss_port.ByteSize = 8; //数据位
ss_port.Parity = 0; //奇偶校验
ss_port.StopBits = 1;//停止位
ss_port.ReadTimeout = 1000; //读超时
try
{
if (ss_port.Opened)
{
ss_port.Close();
ss_port.Open(); //打开串口
}
else
{
ss_port.Open();//打开串口
}
return true;
}
catch(Exception e)
{
MessageBox.Show("错误:" + e.Message);
return false;
}
};
}
namespace smsForCSharp
{
public partial class Form1 : Form
{
static JustinIO.CommPort ss_port = new JustinIO.CommPort();
public Form1()
{
InitializeComponent();
}
public bool InitCom(string m_port ,int m_boudrate)
{
ss_port.PortNum = COM1; //端口号
ss_port.dwProvSubType =PST_RS232;//端口类型
ss_port.BaudRate = 19200; //串口通信波特率
ss_port.ByteSize = 8; //数据位
ss_port.Parity = 0; //奇偶校验
ss_port.StopBits = 1;//停止位
ss_port.ReadTimeout = 1000; //读超时
try
{
if (ss_port.Opened)
{
ss_port.Close();
ss_port.Open(); //打开串口
}
else
{
ss_port.Open();//打开串口
}
return true;
}
catch(Exception e)
{
MessageBox.Show("错误:" + e.Message);
return false;
}
}
}
}