How to do this in VB.NET?

▼魔方 西西 提交于 2019-12-11 13:36:51

问题


i having problem in converting this C# code into VB.net. The loadLecturer seem to be having problem after convert to VB.NET

VB code just afterInitializeComponent()

context.Load(context.GetLecturesQuery(), LoadLecturer, Nothing)

The C# code i wish to convert and debug

private void LoadLecturer(LoadOperation<tblLecturer> obj)
{
    foreach (var item in obj.Entities)
    {
        cbLID.Items.Add(item.lecturerID + " - " + item.lfirstName + " " + item.llastName);
    }
}

回答1:


Given the comment, it sounds like it's not the method itself which is causing you grief, but how you call it - because in the original code you're using a method group conversion. I suspect it's as simple as:

context.Load(context.GetLecturesQuery(), AddressOf LoadLecturer, Nothing)



回答2:


Following this link for the VB.NET converter this is what I am getting :)

Private Sub LoadLecturer(obj As LoadOperation(Of tblLecturer))
For Each item As var In obj.Entities
    cbLID.Items.Add(Convert.ToString(item.lecturerID) & " - " & Convert.ToString(item.lfirstName) & " " & Convert.ToString(item.llastName))
Next
End Sub



回答3:


Private Sub LoadLecturer(obj As LoadOperation(Of tblLecturer))
    For Each item As var In obj.Entities
        cbLID.Items.Add(Convert.ToString(item.lecturerID) & " - " & Convert.ToString(item.lfirstName) & " " & Convert.ToString(item.llastName))
    Next
End Sub


来源:https://stackoverflow.com/questions/8047249/how-to-do-this-in-vb-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!