Beispiel für eine Klasse mit diversen Mitgliedern

Das erste Listing zeigt die Implementierung der Klasse Person mit zwei Konstruktoren, einem parameterlosen Konstruktor und einem Konstruktor mit zwei Parametern.

Namespace de.WWWings Public Class Person ' ========== Attribute (Fields) Public PersonalausweisNr As String Public Vorname As String Public Nachname As String ' ========== Errechnete Attribute (Properties) Public ReadOnly Property GanzerName() As String Get Return Me.Vorname & " " & Me.Nachname End Get End Property ' ========== Konstruktoren Public Sub New() End Sub Public Sub New(ByVal Nachname As String, ByVal Vorname As String) Me.Vorname = Vorname Me.Nachname = Nachname End Sub ' ========== Methoden Public Overridable Sub Info() Console.WriteLine("Person: ...

Get Microsoft .NET 4.0 - Crashkurs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.