Implement a program to calculate area of circle using parameterized constructor in VB.net








Module Module1

    Class Area

        Private r As Double

        Public Sub New(ByVal temp As Double)

            r = temp

 

        End Sub

        Public Function getArea() As Double

            Return Math.PI * MathPow(r, 2)

        End Function

    End Class

    Sub Main()

        Dim a As New Area(5.0)

        Console.Write("Area of Circle :{0}", a.getArea())

        Console.ReadKey()

 

    End Sub

 

End Module



Output: 
Area of Circle:78.5398


Comments

  1. Error 1 'MathPow' is not declared. It may be inaccessible due to its protection level. C:\Users\PRANAY\AppData\Local\Temporary Projects\ConsoleApplication1\Module1.vb 17 30 ConsoleApplication1

    ReplyDelete

Post a Comment

If you have any query, please let us know