草庐IT

KeepalivePacket

全部标签

c# - 类型 T 的表达式不能由类型 X 的模式处理

我已将我的项目升级为面向C#7并使用VisualStudio2017RC在我的解决方案中实现模式匹配。这样做之后,引入了一些与使用通用参数进行模式匹配有关的错误。考虑以下代码:publicclassPacket{}publicclassKeepalivePacket:Packet{}publicvoidSend(Tpacket)whereT:Packet{if(packetisKeepalivePacketkeepalive){//Dostuffwithkeepalive}switch(packet){caseKeepalivePacketkeepalivePacket://Dostu

c# - 类型 T 的表达式不能由类型 X 的模式处理

我已将我的项目升级为面向C#7并使用VisualStudio2017RC在我的解决方案中实现模式匹配。这样做之后,引入了一些与使用通用参数进行模式匹配有关的错误。考虑以下代码:publicclassPacket{}publicclassKeepalivePacket:Packet{}publicvoidSend(Tpacket)whereT:Packet{if(packetisKeepalivePacketkeepalive){//Dostuffwithkeepalive}switch(packet){caseKeepalivePacketkeepalivePacket://Dostu