0

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?

1
  • 1
    This is not an answer, but note that the memory load for Stuff is incredibly tiny compared to updating a UI control and painting. 5 orders of magnitude? Probably more. Commented Jan 30, 2014 at 21:09

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Ok, thank you. That is what I thought, but I was making sure that what out saying where the variable was if it was doing something else and slowing down the program.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.