My VB example code.
This is the code I wrote in VB that I'm going to learn to convert to IL all by my very self.
<Assembly: AssemblyTitle("MyILTest")>
<Assembly: AssemblyDescription("This is the VB code that I'm going to learn to convert to IL")>
<Assembly: AssemblyCompany("Geoff Inc.")>
<Assembly: AssemblyProduct("VBConsoleApp")>
<Assembly: AssemblyCopyright("Hands off")>
<Assembly: AssemblyTrademark("Hands off(tm)")>
<Assembly: CLSCompliant(True)>
<Assembly: Guid("948684E5-F1D6-4F9F-B6E8-E28D20E8101D")>
<Assembly: AssemblyVersion("1.0.*")>
Public Interface ISimpleInterface
Sub SimpleSub()
Function SimpleFunction() As Int32
End Interface
Public Interface IMediumInterface
Inherits ISimpleInterface
Sub MediumSub(ByVal firstArgument As Int32)
Function MediumFunction(ByVal firstArgument As Int32) As Int32
End Interface
Public Interface IHardInterface
Inherits IMediumInterface
Function HardFunction(ByVal ParamArray numberSeries() As Int32) As IMediumInterface
Sub HardSub(ByRef mediumVersion As IMediumInterface)
End Interface
Public Class SimpleClass
Implements ISimpleInterface
Public Sub SimpleSub() Implements ISimpleInterface.SimpleSub
Console.WriteLine("This is a simple sub")
End Sub
Public Function SimpleFunction() As Int32 Implements ISimpleInterface.SimpleFunction
Dim i As Int32
Dim j As Int32
i = 13
j = i * 53
Return j - i
End Function
End Class
Public Class MediumClass
Inherits SimpleClass
Implements IMediumInterface
Private mlArgument As Int32
Public Sub MediumSub(ByVal firstArgument As Integer) Implements IMediumInterface.MediumSub
Dim sMessage As String
sMessage = String.Format("This is a medium sub - {0}, {1}", firstArgument, mlArgument)
Console.WriteLine(sMessage)
End Sub
Public Function MediumFunction(ByVal firstArgument As Integer) As Integer Implements IMediumInterface.MediumFunction
Dim lRet As Int32
lRet = System.Convert.ToInt32(System.Math.Sqrt(firstArgument))
mlArgument = firstArgument + 5
Return lRet
End Function
End Class
Public Class HardClass
Inherits MediumClass
Implements IHardInterface
Public Sub HardSub(ByRef mediumVersion As IMediumInterface) Implements IHardInterface.HardSub
mediumVersion = CType(Me, IMediumInterface)
End Sub
Public Function HardFunction(ByVal ParamArray numberSeries() As Int32) As IMediumInterface Implements IHardInterface.HardFunction
Dim lTotal As Int32 = 0
For Each lNumber As Int32 In numberSeries
lTotal += lNumber
Next
If (lTotal And 123) = 123 Then
Console.WriteLine(True)
Else
Console.WriteLine(False)
End If
Return New MediumClass
End Function
Public Property SomeProperty() As Boolean
Get
Return False
End Get
Set(ByVal Value As Boolean)
Console.WriteLine(System.Convert.ToString(Value))
End Set
End Property
End Class
Module MainModule
Public Sub Main()
Dim oTest As New HardClass
Dim oMediumClass As MediumClass
Dim lArgument As Int32 = 13
oTest.SimpleSub()
oTest.SimpleFunction()
oTest.MediumSub(oTest.MediumFunction(lArgument))
oTest.HardSub(DirectCast(oTest, IMediumInterface))
oMediumClass = CType(oTest.HardFunction(1, 2, 3, 4, 5), MediumClass)
End Sub
End Module