Section 10.7. Generic Methods


10.7. Generic Methods

Type members (functions and sub procedures) can also be defined with type parameters, whether or not the class in which they appear uses generics . The type parameter information appears between the defined method name and its regular parameter list.

     Public Sub GenericMessage(Of T As System.Windows.Forms.Control) _           (ByVal preamble As String, ByVal someObject As T)        MsgBox(preamble & ": " & someObject.Location.ToString(  ))     End Sub 

All of the multiple parameter, constraint, and member usage rules that apply to generic classes also apply to generic members.




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net