Stuggling to understand some C# syntax and convert it to VB.


public class wwBusinessObject<TEntity,TContext>
           where TEntity: class, new()
           where TContext: wwDataContext, new()
this.TableInfo = new TableInfo(Context, typeof(TEntity));

I Have:

Public Class BaseClass(Of TEntity As {Class, New})
Me.TableInfo = New TableInfo(db, TypeOf (TEntity))

however it is telling me TEntity is a type and cannot be used as an expression.

I guess

where TEntity: class, new()

creates an instance of TEntity? Do you know how I achieve this in VB keeping in mind we have no idea what type of class TEntity is?


I don't understand what you're doing here. Do you have a C# class that you want to convert to VB.NET? Please post the full class for the working language.

Also the C# tyepof() operator is called GetType() in VB.NET, but from your code post it looks like you are trying to use the C# operator in VB.NET. This is probably the error you're getting:

Me.TableInfo = New TableInfo(db, TypeOf(TEntity))

Should be:

Me.TableInfo = New TableInfo(db, GetType(TEntity))