views:

489

answers:

2

Hi,

I am using Rob Connery's excellent MVC Storefront as a loose basis for my new MVC Web App but I'm having trouble porting the LazyList code to VB.NET (don't ask).

It seems that VB doesn't allow the GetEnumerator function to be specified twice with only differing return types. Does anyone know how I might get around this?

Thanks

Private Function GetEnumerator() As IEnumerator(Of T) Implements IEnumerable(Of T).GetEnumerator
  Return Inner.GetEnumerator()
End Function

Public Function GetEnumerator() As IEnumerator Implements IList(Of T).GetEnumerator
  Return DirectCast(Inner, IEnumerable).GetEnumerator()
End Function
A: 

Sorry, I don't know how to get around this using VB, but one of the advantages of .NET is that at runtime you can use assemblies built using different languages. Therefore, you could create a very simple C# assembly containing the LazyList class and just reference that assembly. This is the whole point of the cross-language re-use that .NET enables - it saves you from reinventing the wheel!

Simon Steele
+2  A: 

VB.NET allows you to specify a name for the function which differs from the function you are implementing.

Public Function GetEnumerator() As IEnumerator(Of T) _
  Implements IEnumerable(Of T).GetEnumerator

  Return Inner.GetEnumerator()
End Function

Public Function GetListEnumerator() As IEnumerator _
  Implements IList(Of T).GetEnumerator

  Return DirectCast(Inner, IEnumerable).GetEnumerator()
End Function
BlackMael