如何使用Lamba表达式将C#转换为VB [英] How to convert C# to VB with Lamba Expressions

查看:76
本文介绍了如何使用Lamba表达式将C#转换为VB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用在线转换器从C#转换了以下代码,但似乎无法使其正常工作。我收到多个错误。 表达预期为Do,'C未声明'',Missing Endif,''公共事件Tapped不能直接调用''。任何人都可以提供正确的VB代码或任何建议吗?



原始C#代码:



I have coverted the following code from C# using a online converter but can''t seem to get it working. I get multiple errors. ''Expression Expected'' for the Do, ''C is not declared'', Missing Endif, ''Public event Tapped cannot be called directly''. Can anyone provide the proper VB code or any suggestions?

The Original C# code:

public void LoadGraphics(GraphicsDevice device)
     {
         _bg.BeginLoad(c =>
             {
                 _gui = c.Load<Window>(@"Data\GUI\Options");
                 RegisterInput();

                 if (_gui.Controls.ContainsKey("back"))
                     _gui.Controls["back"].Tapped += (s, v) => { if (PrevScreen != null) Manager.TransitionTo(PrevScreen); };

                 _renderer = new RenderEngine();
                 _gui.RegisterVisuals(_renderer);
                 _renderer.LoadGraphics(c, device);

                 _sb = new SpriteBatch(device);

                 IsLoaded = true;
             });
     }







The Coverted VB代码:






The Coverted VB code:

Public Sub LoadGraphics(device As GraphicsDevice)
    _bg.BeginLoad(Function(c) Do
        _gui = c.Load(Of Window)("Data\GUI\Options")
        RegisterInput()

        If _gui.Controls.ContainsKey("back") Then
            _gui.Controls("back").Tapped += Function(s, v) Do
                If PrevScreen IsNot Nothing Then
                    Manager.TransitionTo(PrevScreen)
                End If
            End Function
        End If

        _renderer = New RenderEngine()
        _gui.RegisterVisuals(_renderer)
        _renderer.LoadGraphics(c, device)

        _sb = New SpriteBatch(device)

        IsLoaded = True
    End Function)
End Sub

推荐答案

http://msdn.microsoft.com/en-us/library/bb531253%28v=vs.100%29.aspx [ ^ ]



LINQ& amp; Lamda表达式 [ ^ ]



http:// msdn.microsoft.com/en-us/magazine/cc163362.aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/bb531253%28v=vs.100%29.aspx[^]

Basics of LINQ & Lamda Expressions[^]

http://msdn.microsoft.com/en-us/magazine/cc163362.aspx[^]


这篇关于如何使用Lamba表达式将C#转换为VB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆