Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- Class C
- Implements IDisposable
- Public Sub Close() Implements IDisposable.Dispose
- Console.WriteLine("Closing...")
- End Sub
- End Class
- Class Person
- Public Property Name As String
- Public Function GetName() As String
- Return Name
- End Function
- Public Overrides Function ToString() As String
- Return Name
- End Function
- End Class
- Class Student
- Inherits Person
- Implements PostOfficeUser
- Public Property Matr As String
- Function ShowMeInPostOffice() As String Implements PostOfficeUser.ShowMe
- Return "sono uno studente e mi chiamo " + Name
- End Function
- Public Shadows Function GetName() As String
- Return Name & " - Matr: " & Matr
- End Function
- Public Overrides Function ToString() As String
- Return MyBase.ToString() & " - Matr: " & Matr
- End Function
- End Class
- Sub PrintPerson(p As Person)
- Console.WriteLine("Chiamando ToString: {0}", p)
- Console.WriteLine("Chiamando GetName: {0}", p.GetName())
- End Sub
- Interface PostOfficeUser
- Function ShowMe() As String
- End Interface
- Sub PostOfficePresentation(e As PostOfficeUser)
- Console.WriteLine(e.ShowMe())
- End Sub
- Sub Main()
- Dim p As New Person() With {.Name = "Paperino"}
- Dim s As New Student() With {.Name = "Qui", .Matr = "12345"}
- PrintPerson(p)
- PrintPerson(s)
- Console.WriteLine("GetName di Student: {0}", s.GetName())
- 'PostOfficePresentation(p)
- PostOfficePresentation(s)
- Console.ReadLine()
- End Sub
- Sub Main1()
- Using f As New System.IO.FileStream("pippo", System.IO.FileMode.Create)
- End Using
- Using o As New C
- Console.WriteLine("Dentro Using...")
- End Using
- Console.WriteLine("Dopo Using...")
- Console.ReadLine()
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement