View Single Post
  #2 (permalink)  
Old September 9th, 2007, 10:35 AM
planoie's Avatar
planoie planoie is offline
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Generally all .NET code is type safe as that is a feature of the framework (until you venture into unsafe code development).

You would better satisfy the encapsulation principle by exposing your button text property as a propety on the form. That way the calling code doesn't need to know about the controls itself, and you could also change what is encapsulated without breaking callers.

Put a property like this in Form1:

public string ButtonText{
   get{ return button1.Text; }
   set{ button1.Text = value; }
}

-Peter