VB.net Program to Demonstrate Set and Get Properties With Structure

You are currently viewing VB.net Program to Demonstrate Set and Get Properties With Structure

VB.Net program to demonstrate Set and Get properties with structure

'VB.net program to demonstrate 
'Set and Get properties with structure.

Structure Student
    Dim Id As Integer
    Dim Name As String

    Public Property StudentID As Integer
        Get
            Return Id
        End Get
        Set(value As Integer)
            Id = value
        End Set
    End Property

    Public Property StudentName As String
        Get
            Return Name
        End Get
        Set(value As String)
            Name = value
        End Set
    End Property
End Structure

Module Module1
    Sub Main()
        Dim Stu As New Student()

        Stu.StudentID = 1000
        Stu.StudentName = "Karan Malhotra"

        Console.WriteLine("Student Id  : {0}", Stu.StudentID)
        Console.WriteLine("Student Name: {0}", Stu.StudentName)
    End Sub
End Module
Student Id  : 1000
Student Name: Karan Malhotra
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