0

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

For:

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?

Thanks

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by sknake
0

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))
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.