views:

110

answers:

1

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()> _
<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 :)

+1  A: 

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
Pavel Minaev
Weird, when I put everything on the same line it gives me the message same as when I add the _ for continuation. But works as above when I don't add a continuation but put it on the next line. Thank you for the answer, it should have been obvious.
Romel Evans
That's the point. When you put everything on the same line, it's exactly the same as when you separate lines by `_` (it's the whole point of a line continuation character - it effectively suppresses the following newline, as if it wasn't there).
Pavel Minaev