I have two sub routines, each conclude the same results, but I'd like to know which one is preferred and/or which one if not both are incorrect.
Question 1;
I use a string variable to hold the status of a running service.
I then output that variable on to the form via a text box or label for instance.
If I then want to be efficient further in the routine, can I reuse the aforementioned string or should I create a new.
For example,
Is this actually saving any memory, is it bad coding, is it just plain wrong or pointless?
Question 2;
Microsoft example,
Other than the obvious, is there any difference between that method, and this;
Thanks
Danny
Question 1;
I use a string variable to hold the status of a running service.
I then output that variable on to the form via a text box or label for instance.
If I then want to be efficient further in the routine, can I reuse the aforementioned string or should I create a new.
For example,
VB.NET:
Dim vString As String = ("example one")
Textbox1.Text = vString
vString = New String("example two")
Textbox2.Text = vString
Is this actually saving any memory, is it bad coding, is it just plain wrong or pointless?
Question 2;
Microsoft example,
VB.NET:
Dim TheServiceName As String = "MSSQL$SQLEXPRESS"
Dim mySC As ServiceController
mySC = New ServiceController(TheServiceName)
Other than the obvious, is there any difference between that method, and this;
VB.NET:
Dim mySC As New ServiceController("MSSQL$SQLEXPRESS")
Thanks
Danny