@bobnoordam

Demonstration of structures and enumerable types

Module Module1
  
    ' MCTS70-536-1-2
    ' VB.NET
  
    ' Demonstration of a structure and an override of the ToString method to display
    ' all parts of our person
  
    Public Structure Person
  
        ' --- Example of an enumaration, see the actual Main() Method for use
        Enum Genders
            Male
            Female
        End Enum
  
        Private _firstname As String
        Private _lastname As String
        Private _age As Integer
        Private _gender As Genders
  
        Public Property Gender() As Genders
            Get
                Return _gender
            End Get
            Set(ByVal value As Genders)
                _gender = value
            End Set
        End Property
  
        Public Property firstName() As String
            Get
                Return _firstname
            End Get
            Set(ByVal value As String)
                _firstname = value
            End Set
        End Property
  
        Public Property lastName() As String
            Get
                Return _lastname
            End Get
            Set(ByVal value As String)
                _lastname = value
            End Set
        End Property
  
        Public Property age() As Integer
            Get
                Return _age
            End Get
            Set(ByVal value As Integer)
                _age = value
            End Set
        End Property
  
        Public Sub New(ByVal _firstname As String, ByVal _lastname As String, ByVal _age As Integer, ByVal _gender As Genders)
            firstName = _firstname
            lastName = _lastname
            age = _age
            Gender = _gender
        End Sub
  
        Public Overrides Function ToString() As String
  
            Return firstName & " " & lastName & ", " & age.ToString & " " & Gender.ToString
  
        End Function
  
    End Structure
  
    Sub Main()
  
        Dim x As New Person("Jan", "Aap", 42, Person.Genders.Male)
        Console.WriteLine(x.ToString)
  
        ' --- Change gender of our struct
        x.Gender = Person.Genders.Female
        Console.WriteLine(x.ToString)
  
        Console.Write(">>")
        Console.ReadLine()
  
    End Sub
  
End Modul