2012-01-02 47 views
0

我收到上述錯誤。它在開發模式下工作,但不是在現場,有任何想法?表達式是一個值,因此不能作爲賦值的目標 - asp.net

有作爲,我會將它們寫入一個文本文件閱讀器正確的價值觀....

 Do While reader.Read() 
      personList.Add(New Person() With {.ID = reader("user_id"), .Name = reader("person")}) 
     Loop 

感謝,

Public Class Person 
Private m_ID As Integer 
Public Property ID() As Integer 
    Get 
     Return m_ID 
    End Get 
    Set(ByVal value As Integer) 
     m_ID = value 
    End Set 
End Property 
Private m_Name As String 
Public Property Name() As String 
    Get 
     Return m_Name 
    End Get 
    Set(ByVal value As String) 
     m_Name = value 
    End Set 
End Property 
+0

我們可以看到Person類嗎?至少是屬性。 – 2012-01-02 14:23:06

+0

http://msdn.microsoft.com/en-us/library/76435b93(VS.80).aspx – Aristos 2012-01-02 14:27:06

+0

添加屬性 – thegunner 2012-01-02 14:33:57

回答

0

現在排序,只是做它用不同的方式。得到新的構造函數來獲取參數並設置它們。把它們作爲可選的,因爲構造被稱爲別處,而不需要參數。

Public Sub New(Optional ByVal uid As Integer = 0, Optional ByVal uname As String = "") 
    ID = uid 
    Name = uname 
End Sub 


Dim uid As Integer 
Dim uname As String 
Do While reader.Read() 
    uid = reader("user_id") 
    uname = reader("person") 
    personList.Add(New Person(uid, uname)) 
Loop