title: Shared Variables lifetime
body: <p>When are Shared (Static) variables created and destroyed.  For example have a look at the code below:</p>
  
  <pre><code> Imports System.Data.SqlClient
   Public Class Form1
  
          Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
              Person.testCon = New SqlConnection
              Person.Age = 30
              Dim p1 As Person
          End Sub
      End Class
  
  Imports System.Data.SqlClient
      Public Class Person
          Public Shared testCon As SQLConnection
      End Class
  </code></pre>
  
  <p>The testCon variable is accessible from the Form_Load before the first instance of Person is created.  I realise that it is probably not good practice to have a connection as a shared variable but I want to get my point across.  I also want to know when variables are created and destroyed if they are primitives (like Person.Age in the example)</p>