Jim
Jim

Reputation: 1

C# to VB question

I can achieve in VB what the following C# snippet does but it seems very clunky since I perform a Linq query to obtain the events for the relevant user. Is there a neat way?

          ctx.FetchEventsForWhichCurrentUserIsRegistered((op) =>
            {
                if (!op.HasError)
                {
                    var items = op.Value;
                    _currentUserRegisteredEventIds = new HashSet<int>(items);
                    UpdateRegistrationButtons();
                }
            }, null);
        }
        else
        {
            _currentUserRegisteredEventIds = null;
            UpdateRegistrationButtons();
        }

Upvotes: 0

Views: 142

Answers (2)

TobyEvans
TobyEvans

Reputation: 1461

Reflector is always useful for this - compile your code, then disassemble and convert to your chosen language. I've not used this personally, but this add-in seems to even export the code into a project as well: http://filegenreflector.codeplex.com/

Upvotes: 0

Sonic Soul
Sonic Soul

Reputation: 24919

ctx.FetchEventsForWhichCurrentUserIsRegistered(Function(op) Do
    If Not op.HasError Then
        Dim items = op.Value
        _currentUserRegisteredEventIds = New HashSet(Of Integer)(items)
        UpdateRegistrationButtons()
    End If
End Function, Nothing)

i found the following web app to be useful for this: http://www.developerfusion.com/tools/convert/vb-to-csharp/

although minor tweaking is sometimes required

Upvotes: 1

Related Questions