This is a migrated thread and some comments may be shown as answers.

C# to VB variable conversion

1 Answer 153 Views
Code Converter
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
William
Top achievements
Rank 1
William asked on 22 Jun 2013, 07:50 PM
 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
        Next
but should be:
        For Each var as eventInfo In MyBase.GetEventInfos(state, hierarchicalItem)
            Yield eventInfo         Next

1 Answer, 1 is accepted

Sort by
0
Aleksander
Top achievements
Rank 1
answered on 11 Jul 2013, 08:05 AM
Actually, shouldn't it just be

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

"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).
Tags
Code Converter
Asked by
William
Top achievements
Rank 1
Answers by
Aleksander
Top achievements
Rank 1
Share this question
or