using System;
class Program
{
static void Main(string[] args)
{
(new Program()).Method();
Console.ReadLine();
}
public void Method()
{
int a1 = calcArea(2, 3);
Console.WriteLine("Area with parameters is: {0}", a1);
int a2 = calcArea();
Console.WriteLine("Area without parameters is: {0}", a2);
}
private int calcArea(int l = 4, int w = 5)
{
return l * w;
}
}
|
Class Program
Private Shared Sub Main(args As String())
(New Program()).Method()
Console.ReadLine()
End Sub
Public Sub Method()
Dim a1 As Integer = calcArea(2, 3)
Console.WriteLine("Area with parameters is: {0}", a1)
Dim a2 As Integer = calcArea()
Console.WriteLine("Area without parameters is: {0}", a2)
End Sub
Private Function calcArea(Optional l As Integer = 4, Optional w As Integer = 5) As Integer
Return l * w
End Function
End Class
|