String concatenation: Final string value does not equal to the latest value

Posted by Pan Pizza on Stack Overflow See other posts from Stack Overflow or by Pan Pizza
Published on 2012-04-12T10:33:41Z Indexed on 2012/04/12 11:28 UTC
Read the original article Hit count: 579

I have a simple question about string concatenation. Following is the code. I want to ask why s6 = "abcde" and not "akcde"? I have change the s2 value to "k".

Public Class Form1
    Public s1 As String = "a"
    Public s2 As String = "b"
    Public s3 As String = "c"
    Public s4 As String = "d"
    Public s5 As String = "e"
    Public s6 As String = ""
    Public s7 As String = "k"

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        s6 = s1 & s2 & s3 & s4 & s5
        s2 = s7
        MessageBox.Show(s6) 's6 = abcde

    End Sub
End Class

© Stack Overflow or respective owner

Related posts about .NET

Related posts about vb.net