C#类与类之间的函数怎么调用. 5
我建立了2个类,第1个对通信口的底层操作类,对外色函数都是staticusingSystem;usingSystem.Collections.Generic;usingS...
我建立了2个类,
第1个对通信口的底层操作类,对外色函数都是static
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace 2016Net
{
public class MyCom
{
/// <summary>
/// 打开通讯口
/// </summary>
public static void ComOpen()
{
......
}
/// 关闭通讯口
/// </summary>
public static void ComClose()
{
......
}
/// <summary>
/// 读信息
/// </summary>
/// <param name="NumBytes"></param>
/// <returns></returns>
public static byte[] ComRead(int NumBytes)
{
.....
return OutBytes;
}
/// <summary>
/// 写信息
/// </summary>
/// <param name="WriteBytes"></param>
/// <returns></returns>
public static int ComWrite(byte[] WriteBytes)
{
int BytesWritten = 0;
......
return BytesWritten;
}
}
}
第2个是通讯协议类,就是对通讯口发出与设备的协议
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics; //Process
using System.ComponentModel;
using 2016Net;
namespace 2016Net
{
class Protocol_XXXX
{
public string GetDateTime_(byte MachNo)
{
......
///怎么调用,发协议
MyCom.ComWrite(sendbyte);
///怎么调用,接受返回协议
ReceiveString = MyCom..ComRead(16);
}
public string SetDateTime_(byte MachNo)
{
......
}
}
}
引用
MyCom com = new MyCom();
com.找不到“ComWrite”和“ComRead”
用
MyCom.也找不到“ComWrite”和“ComRead”
在网上也查了,没有这方面的例子,希望高手指点..... 展开
第1个对通信口的底层操作类,对外色函数都是static
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace 2016Net
{
public class MyCom
{
/// <summary>
/// 打开通讯口
/// </summary>
public static void ComOpen()
{
......
}
/// 关闭通讯口
/// </summary>
public static void ComClose()
{
......
}
/// <summary>
/// 读信息
/// </summary>
/// <param name="NumBytes"></param>
/// <returns></returns>
public static byte[] ComRead(int NumBytes)
{
.....
return OutBytes;
}
/// <summary>
/// 写信息
/// </summary>
/// <param name="WriteBytes"></param>
/// <returns></returns>
public static int ComWrite(byte[] WriteBytes)
{
int BytesWritten = 0;
......
return BytesWritten;
}
}
}
第2个是通讯协议类,就是对通讯口发出与设备的协议
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics; //Process
using System.ComponentModel;
using 2016Net;
namespace 2016Net
{
class Protocol_XXXX
{
public string GetDateTime_(byte MachNo)
{
......
///怎么调用,发协议
MyCom.ComWrite(sendbyte);
///怎么调用,接受返回协议
ReceiveString = MyCom..ComRead(16);
}
public string SetDateTime_(byte MachNo)
{
......
}
}
}
引用
MyCom com = new MyCom();
com.找不到“ComWrite”和“ComRead”
用
MyCom.也找不到“ComWrite”和“ComRead”
在网上也查了,没有这方面的例子,希望高手指点..... 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询