我必须将我的c#转换为vb,但它没有100%转换,我坚持用类对象添加项目。
我在此处收到错误(类型'布尔值'无法转换为' _Default.Courses')在课程列表中添加:
Public Class Courses
Public courseName As String
Public qualName As String
Public providerName As String
End Class
...
While r.Read
Dim coursename As String = r("courseName").ToString
Dim qualname As String = r("qualName").ToString
Dim providername As String = r("providerName").ToString
courseList.Add(New Courses() With {
Key.courseName = coursename,
Key.qualName = qualname,
Key.providerName = providername
})
End While
...
这是原始的c#代码:
while (r.Read())
{
string coursename = r["courseName"].ToString();
string qualname = r["qualName"].ToString();
string providername = r["providerName"].ToString();
courseList.Add(new Courses
{
courseName = coursename,
qualName = qualname,
providerName = providername
});
}
答案 0 :(得分:0)
将您的代码更改为:
While r.Read
Dim coursename As String = r("courseName").ToString
Dim qualname As String = r("qualName").ToString
Dim providername As String = r("providerName").ToString
courseList.Add(New Courses() With {
.courseName = coursename,
.qualName = qualname,
.providerName = providername
})
End While