July 2003
Intermediate to advanced
736 pages
16h 35m
English
The DefaultMemberAttribute is applied to a type and takes a string argument indicating the name of the default member. The default member can be invoked by InvokeMember without passing the name of the member to invoke. For example, if we apply the DefaultMemberAttribute to ReflectedClass, naming the HelloWorld method as the default member, we can invoke HelloWorld without naming the method. Listing 4.7 shows the ReflectedClass class and a call to InvokeMember that relies on the DefaultMemberAttribute.
Imports System.Reflection <DefaultMember("HelloWorld")> _ Public Class ReflectedClass Private FMessage As String Public Sub New(ByVal Message As String) FMessage ... |
Read now
Unlock full access