VB Get Set Example

GET SET Example

Imports System.Collections.Generic
Imports System.Linq
Imports System.Text

Namespace Program11
    Class Employee
        Private code As Integer
        Private name As String
        Private designation As String

        Public Property Code As Integer
            Get
                Return code
            End Get
            Set(ByVal value As Integer)
                code = value
            End Set
        End Property

        Public Property Name As String
            Get
                Return name
            End Get
            Set(ByVal value As String)
                name = value
            End Set
        End Property

        Public Property Designation As String
            Get
                Return designation
            End Get
            Set(ByVal value As String)
                designation = value
            End Set
        End Property
    End Class

    Class Program
        Private Shared Sub Main(ByVal args As String())
            Dim emp As Employee = New Employee()
            Console.WriteLine("Enter Code ")
            emp.Code = Integer.Parse(Console.ReadLine())
            Console.WriteLine("Enter Employee Name")
            emp.Name = Console.ReadLine()
            Console.WriteLine("Enter Employee Designaiton")
            emp.Designation = Console.ReadLine()
            Console.WriteLine("Code= " & emp.Code)
            Console.WriteLine("Name= " & emp.Name)
            Console.WriteLine("Designation=" & emp.Designation)
        End Sub
    End Class
End Namespace


©Copyright 2016 All Rights Reserved LearnDotNetHome.com