View Single Post
  #2 (permalink)  
Old May 21st, 2011, 10:11 AM
Rod Stephens's Avatar
Rod Stephens Rod Stephens is offline
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

By default in C# a control's variable is declared private so other form's can't access it directly. You can change that by setting it's Modifiers property to public.

Purists argue that you should not do this, that instead you should create a public property to get and set the control's value. In this case you would create a Name property that would get and set NameTextBox.Text.

I don't think it's that big a deal because it's pretty clear how you use a TextBox so code outside the form is less likely to mess it up. So I'd probably just set the Modifier to public and you should be good to go.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)