C# to VB variable conversion

2 posts, 0 answers
  1. William
    William avatar
    2 posts
    Member since:
    Sep 2010

    Posted 22 Jun 2013 Link to this post

     foreach (var eventInfo in base.GetEventInfos(state, hierarchicalItem))
                yield return eventInfo;
    was converted to:
            For Each eventInfo As var In MyBase.GetEventInfos(state, hierarchicalItem)
                Yield eventInfo
    but should be:
            For Each var as eventInfo In MyBase.GetEventInfos(state, hierarchicalItem)
                Yield eventInfo         Next
  2. Aleksander
    Aleksander avatar
    1 posts
    Member since:
    Nov 2011

    Posted 11 Jul 2013 Link to this post

    Actually, shouldn't it just be

    For Each eventInfo In MyBase.GetEventInfos(state, hierarchicalItem)
        Yield eventInfo

    "var" relies on type-inference, no reason to type the variable in VB.NET then. Although, this requires the "Option Infer" to work.

    One thing I can say for sure is that "var As eventInfo" is definitely wrong. It would make "Yield eventInfo" not work as expected (if it even compiles).
Back to Top