我将此C#代码转换为VB.net时遇到问题。 loadLecturer在转换为VB.NET后似乎有问题
VB代码就在afterInitializeComponent()
之后context.Load(context.GetLecturesQuery(), LoadLecturer, Nothing)
我希望转换和调试的C#代码
private void LoadLecturer(LoadOperation<tblLecturer> obj)
{
foreach (var item in obj.Entities)
{
cbLID.Items.Add(item.lecturerID + " - " + item.lfirstName + " " + item.llastName);
}
}
答案 0 :(得分:3)
鉴于评论,听起来这不是导致你悲伤的方法本身,而是你如何调用 - 因为在原始代码中你正在使用方法组转换。我怀疑它很简单:
context.Load(context.GetLecturesQuery(), AddressOf LoadLecturer, Nothing)
答案 1 :(得分:1)
点击此链接for the VB.NET converter这就是我得到的内容:)
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
答案 2 :(得分:0)
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