silverstormboy Posted January 23, 2003 Posted January 23, 2003 hi , I have a question regarding property in vb.net. for ex: i have a statusbar control in the form name statusBar and value text = "". then i create the property as follows: Public Property StatusText() as String Get Return statusBar.Text End Get Set(ByVal Value As String) statusBar.Text = Value End Set End Property after that, to call this property : StatusText = "Ready" What is the use of property in vb.net? why can't we just type: statusBar.Text = "Ready" instead of creating the property? Some book say that property is very useful and important in vb.net but I do not see it. Please give me advice about this , Thanks. Quote
TechnoTone Posted January 23, 2003 Posted January 23, 2003 The only reason that I can see why you would do it like that is so that you can set the StatusText property from outside of the form. Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
*Gurus* divil Posted January 23, 2003 *Gurus* Posted January 23, 2003 Exactly. Properties are an interface between private fields and the outside world. If you have a control that paints itself, you need a text property, so that when the user calls the Set method, you know to redraw your control. For more info on properties, I suggest you read the documentation. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.