views:

100

answers:

2

Hi,

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();
        }
+1  A: 
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

Sonic Soul
Thanks for this but I too have used the site you referred to as well as http://converter.telerik.com/. Sadly the solutions from both sites do not work.
Jim
A: 

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/

TobyEvans
Thanks for this but I'm not sure I want to be challenging my limited skill set by trying a technique in which I have no expertise!
Jim
Hey Jim - Reflector is where you get your skillset from!http://www.red-gate.com/products/reflector/Put your code in a Visual Studio project, build it, then use Reflector to open the compiled assembly - you can convert the code into c# or vb.net.Well worth investing some time in ...
TobyEvans