views:

645

answers:

3

I am more familiar with VB and the book i bought has C# examples, now i am stuck.

How do I implement the following in VB.NET?

public abstract class ENTBaseDATA<T> where T : IENTBaseEntity

{
  public abstract List<T> Select();
  public abstract T Select(int id);

  etc....This code already is converted :)

}

For complete code see Chapter 2 download:

http://www.wrox.com/WileyCDA/WroxTitle/productCd-0470396865,descCd-DOWNLOAD.html

+5  A: 

You could try to use a C# / VB.NET converter. Output:

Public MustInherit Class ENTBaseDATA(Of T As IENTBaseEntity)
    Public MustOverride Function [Select]() As List(Of T)
    Public MustOverride Function [Select](ByVal id As Integer) As T
    ' and then the other code '
End Class
Fredrik Mörk
Thx i tried but it gave an error. Your answer seems to work thx
MustInherit and MustOverride are the Magic Words here - Visual Basic uses two different words for Classes and Members to make the usage more obvious.
Michael Stum
@Michael: yes, in this case it feels like the VB.NET syntax is more imperative, while the c# syntax is more describing. `MustInherit` and `MustOverride` can be put on the developer's TODO list, while `abstract` refers more to the characteristics of the members.
Fredrik Mörk
A: 

You can check some auto-converter, fe. http://www.kamalpatel.net/ConvertCSharp2VB.aspx. If it won't work, you can: create an assembly in c# (just compile your code), download .NET Reflector (if you don't have one! :) ), decompile assembly and convert it to VB.NET

//Edit removed code, as it seems it's broken (eh, those converters ;) ).

Ravadre
+3  A: 

You should know:

Abstract Class:

In C#: abstract keyword

In VB.NET: MustInherit keyword

Abstract Method:

In C#: abstract keyword

In VB.NET: MustOverride keyword

Generic class or method:

In C#: Class<T> where T : Conditions

In VB.NET: Class(Of T As Conditions)

Finally, in VB.NET the word Select is a reserved keyword, so you have to enclose it between [ ] in order to use it.