Generic delegate can point to any method taking a single argument (specified at the time of creation) : Generic Delegate « Generics « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » Generics » Generic DelegateScreenshots 
Generic delegate can point to any method taking a single argument (specified at the time of creation)
  

Option Explicit On
Option Strict On

Public Delegate Sub MyGenericDelegate(Of T)(ByVal arg As T)
Public Delegate Sub MyDelegate(ByVal arg As Object)

Module Program
  Sub Main()
    Dim As New MyGenericDelegate(Of Integer)(AddressOf IntegerTarget)
    d(100)
    Dim d2 As New MyGenericDelegate(Of String)(AddressOf StringTarget)
    d2("Cool!")
  End Sub

  Public Sub IntegerTarget(ByVal arg As Integer)
    Console.WriteLine("You passed me a {0} with the value of {1}", arg.GetType().Name, arg)
  End Sub

  Public Sub StringTarget(ByVal arg As String)
    Console.WriteLine("You passed me a {0} with the value of {1}", arg.GetType().Name, arg)
  End Sub
End Module

   
    
  
Related examples in the same category
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.