John  Burns

John Burns

  • NA
  • 120
  • 109.2k

memory management and variables

Jan 2 2011 6:37 AM
hey guys

i have a small windows forms app with a simple seies of textboxes of int data type (which i created using the local database) and a button.

when i click the button it will simply fill the textboxes with text data

thing is should i be assigning everything to variables first and then using the variable or should i just stick to directly assigning values to the objects? here is an example of what i mean:

 total_OutgoingTextBox.Text = "35";


can i do this? it sure does work but i was thinking, should i be assigning this to a variable first then using the variable instead?

if so i wasnt quite sure how that would be done, here was my attempt to do it (it didnt work though but could find no other way) ... :(


 string tb1 = total_OutgoingTextBox.Text.ToString();
 tb1 = "35";



why wont this work? i even tried taking out the .Text as well. it will compile ok but wont populate the textbox with the 35 i want.

thanks

Answers (8)