0
我必須將我的c#轉換爲vb,但它沒有轉換100%,我堅持使用類對象將項添加到列表。如何添加一個項目與類在VB中的列表?
我在這裏得到錯誤(值類型 '布爾' 不能被轉換爲 '_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
});
}
刪除'Key' – Slai