开发者

In VB.NET how do you specify Inherits/implements on a generic class with multi-constraints

开发者 https://www.devze.com 2023-01-02 17:59 出处:网络
When I write the following statement in VB.Net (C# is my normal language), I get an \"end of statement expected\" referring to the \"Implements\" statement.

When I write the following statement in VB.Net (C# is my normal language), I get an "end of statement expected" referring to the "Implements" statement.

<Serializable()> _
<开发者_C百科;XmlSchemaProvider("EtgSchema")> _
Public Class SerializeableEntity(Of T As {Class, ISerializable, New}) _
Implements IXmlSerializable, ISerializable
...
End Class

The C# version that I'm trying to emulate is:

[Serializable]
[XmlSchemaProvider("MySchema")]
public class SerializableEntity<T> : IXmlSerializable, ISerializable where T : class, new()
{
....
}

Sometimes I feel like I have 5 thumbs with VB.NET :)


In VB, Implements (and Inherits) is a separate clause within the body of the class (on the same level as class members), so you simply need to drop that _ line continuation:

<Serializable()> _
<XmlSchemaProvider("EtgSchema")> _
Public Class SerializeableEntity(Of T As {Class, ISerializable, New})
    Implements IXmlSerializable, ISerializable
    ...
End Class
0

精彩评论

暂无评论...
验证码 换一张
取 消