Exercise
Function returning a value
Objetive
Write a Visual Basic (VB.Net) program whose Main must be like this:
public static void Main()
{
int x= 3;
int y = 5;
Console.WriteLine( Sum(x,y) );
}
"Sum" is a function that you must define and that will be called from inside Main. As you can see in the example, it must accept two integers as parameters, and it must return an integer number (the sum of those two numbers).
Code
Imports System
Public Class exercise99
Public Shared Function Sum(ByVal a As Integer, ByVal b As Integer) As Integer
Dim result As Integer
result = a + b
Return result
End Function
Public Shared Sub Main()
Dim x As Integer = 3
Dim y As Integer = 5
Console.WriteLine(Sum(x, y))
End Sub
End Class