VB.net Program to Demonstrate a Simple Delegate With a Method of a Structure

You are currently viewing VB.net Program to Demonstrate a Simple Delegate With a Method of a Structure

VB.Net program to demonstrate a simple delegate with a method of a structure

'VB.net program to demonstrate a simple delegate 
'with a method of a structure.

Public Delegate Sub MyDelegate()
Structure Sample
    Public Sub SayHello()
        Console.WriteLine("Hello World")
    End Sub
End Structure

Module Module1
    Sub Main()
        Dim S As New Sample()
        Dim del As MyDelegate = AddressOf S.SayHello

        del()
    End Sub
End Module
Hello World
Press any key to continue . . .

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply