Spartin503
Spartin503

Reputation: 47

Efficiency with VB.NET Code

If I had code like this:

Public Module Global_Variables
  Public Stuff as string
End Module

Public Class Stuff_Doer
  Me.TextBox1.Text = Global_Variables.Stuff
End Class

Would it be more efficient to do this:

Public Module Global_Variables
  Public Stuff as string
End Module

Public Class Stuff_Doer
  Me.TextBox1.Text = Stuff
End Class

Or would it be the same as the program would just it behind the scenes anyway?

Upvotes: 0

Views: 248

Answers (2)

Daniel Imms
Daniel Imms

Reputation: 50189

They would result in the same program after compile-time optimizations have occurred.

You shouldn't really consider optimizing something as small as this, even if they were different the difference would absolutely tiny, too small to measure accurately.

Upvotes: 0

Joel Coehoorn
Joel Coehoorn

Reputation: 415810

Assuming there is no name conflict for Stuff, they are the same program and result in the same IL.

Upvotes: 2

Related Questions