Before the visibility of the property, a problem that has been plaguing my problem is that the GET and SET accessors in Visual Basic .NET must have the same accessibility (public, friends, or private). If you want to create a read-only public property (only Get is disclosed), then there is no SET Accessor in your component to force the acknowledgment or custom properties. Now, the GET and SET Accessors in Visual Basic 2005 can set different accessibility, just SETs must be more restricted than get on access: private _myprop as string
Public property myprop () AS STRING
Get return _myprop end get
Friend set (byval value as string) if value.trim.length> 0 Then _myprop = value.trim else value = "
This feature is quite useful for the team's development environment or for personal developers who strive to pursue the maximum reuse rate of code. Custom Event Accessor Event Accessor allows you to define a custom event, and you can control what happens when you add or delete an event processor and trigger your event. Suppose you have a custom class, you causing a ratechanged event in this class. You can declare a normal event as one of the following two ways: Public Event RateChanged () or Public Event Hourschanged As EventHandler declares that events generate an automatic hosted background storage. In other words, the system will handle the way the event hosted and dispatched. Usually this is very good, but sometimes you need to have more control over how to inform the event listener. You can use this new Custom keyword to define a custom event and its access modifier. When you tap the key on the event declaration, Visual Basic 2005 will automatically generate a code original shape, which generates like the Property Accessor: Public Custom Event Namechanged As EventHandler AddHandler (Byval Value As Eventhandler) Merry and background storage hook End AddHandler
RemoveHandler (Byval Value As EventHandler) Removes processor End RemoveHandler from Background Storage
RaiseEvent (Byval E AS Object, Byval E As Eventargs) 'Excited Listener End RaiseEvent
End Event When the client adds or deletes a processor for your event, the addHandler or RemoveHandler has started working. When the event is initiated, the RaiseEvent process starts. In this way, you can take special operations as you want to host the background storage. When you create these custom events in this way, you can treat the event as an attribute. An example showing the custom event accessor uses, is that when your object is sequentially, you have an event that can be processed by an insequence of entrusted objects. If you try to serialize your object through a normal event, serialization will fail because the store is insequently stored in the background. Rocky Lhotka explained a detailed example of the role of Rocky Lhotka, and you can see his blog: http://www.lhotka.net/weblog/commentView.aspx GUID = 776F44E8-AAEC-4845-B649-E0D840E6DE2C. @ The following is the text for reference @Property Accessor AccessibilityAn issue that has always bothered me about Visual Basic .NET properties is that the Get and Set accessors must have the same accessibility (Public, Friend, or Private). If you want to create a read -only public property (only the Get is public), there is no Set accessor you can use within your component to enforce validation or custom property handling. The Get and Set accessors in Visual Basic 2005 can now have different accessibility settings, as long as Set is more restrictive tour: properties _myprop as stringpublic property myprop () AS STRING
Get return _myprop end get
Friend set (byval value as string) if value.trim.length> 0 Then _myprop = value.trim else value = "
End PropertyThis is especially helpful in team development environments and for individual developers striving to get the highest amount of reuse out of their code.Custom Event AccessorsEvent accessors let you define a custom event and control what happens as clients add and remove handlers and raise your event . Suppose you have a custom class in which you raise an event RateChanged you declare normal events in one of two ways:.. Public Event RateChanged () 'orPublic Event HoursChanged As EventHandlerEvents declared in this way have an automatically managed backing store in other words , the system handles how the event is managed and dispatched. Normally this is fine, but sometimes you need more control over how the event's listeners are notified. you declare a custom event and its accessors using the new Custom keyword. When you hit the enter Key on The Event Declaration, Visual Basic 2005 Creates The Code Prototype for you in The Same Way Property Accessors Are Generated: Public Custom e VENT NAMECHANGED AS EventHandler AddHetrandler (Byval Value As Eventhandler) 'Hook Handler To Backing Store End Adddhandler