John.P
John.P

Reputation: 657

Translate C# type param to VB

I'm trying to translate this C# code to VB.net

public List<T> BinaryFileDeSerialize<T>(string filePath) where T : class

But I don't know how to the would look like in vb.net

I tried it like this:

Public Function BinaryFileDeSerialize(ByVal filePath As String) As List(Of T)

But I'm getting an error saying that the T in List(Of T) is not defined.

Upvotes: 0

Views: 37

Answers (1)

MarcinJuraszek
MarcinJuraszek

Reputation: 125620

That's because you're missing the generic type in method declaration. You can't return T without defining it earlier.

Public Function BinaryFileDeSerialize(Of T As { Class })(ByVal filePath As String) As List(Of T)

Upvotes: 1

Related Questions