private string strName = string.Empty;         public string StrName 
        { 
            get 
            { 
                return strName; 
            } 
            set 
            { 
                strName = value; 
                this.textBox1.Text = strName; 
            } 
        } 

解决方案 »

  1.   


    Private strName As String =  String.Empty 
     
            Public Property StrName() As String
             Get 
                    Return strName
             End Get
             Set (ByVal Value As String) 
                    strName = value 
                    Me.textBox1.Text = strName
             End Set
            End Property
      

  2.   

    private string strName = string.Empty;         public string StrName 
            { 
                get 
                { 
                    return strName; 
                } 
                set 
                { 
                    strName = value; 
                    this.textBox1.Text = strName; 
                } 
            } private ReadOnly strName As String = String.Empty
       Public Property StrName() As String
            Get
                Return strName
            End Get
            Set(ByVal value As String)
                strName = value
     Me.textBox1.Text = strName
            End Set
        End Property
      

  3.   

    錯誤 無法在此內容中存取 'WindowsApplication1.FormEditCustomer.strName',因為它是 'Private'。
    'StrName' 已經在此 class 中宣告為 'Private ReadOnly Dim strName As String'了。
    變數 'StrName' 已在指派值之前使用。可能會在執行階段產生 null 參考例外狀況。
    'ReadOnly' 變數不可以是指派的目標。