title: Saving an basic array inside a class public property
body: <p>I am wondering how to save an array inside of a class in VB.Net. This is the form code I have (it gets executed when the program loads).</p>
  
  <pre><code>Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      Dim intArr As Integer() = {5, 3, 8, 1, 4, 6}
      Dim statsObj As New StatsMachine()
      statsObj.Data = intArr
      Dim avg As Double = statsObj.Average()
      txtAvg.Text = FormatNumber(avg, 2)
      txtNumAboveAvg.Text = CStr(statsObj.NumElementsAbove(avg))
  End Sub
  </code></pre>
  
  <p>I am <strong>not allowed</strong> to change this code (this is a problem from the book) and I am supposed to create classes so it can run. </p>
  
  <p>So I created the class "StatsMachine". My first public property, Data, should take the array that is created in this code and save it. Unfortunately I can't get this to work. My code at the moment:</p>
  
  <pre><code>Public Class StatsMachine
      Dim sourceData As Form1
      Dim m_arr() As Integer
  
      Public Property Data As Integer
          Get
              Return m_arr
          End Get
          Set(ByVal value As Integer)
              m_arr() = sourceData.intArr()
          End Set
      End Property
  End Class
  </code></pre>
  
  <p>Visual Studio says sourceData.intArr() is not found. I assume this is because I need to add another identifier when I call it. What would would this be? This actually doesn't just apply to arrays, I don't know how to call things from Form 1.</p>
  
  <p>Thanks!</p>