Constants in Visual Basic .Net

In programming constant is like variable but constant is not going to change once you define it

You can define the constant like this

 

So value of PI is not going to change so it is a constant

I am going to create function to calculate the area of a circle. I will pass the radius as a parameter to the function

Here I have defined the PI outside the function but I am using it inside the function.

If you try to change the value of PI inside the function, you will get compile time message
“Constant can not be target of an assignment”

Leave a Reply

Your email address will not be published. Required fields are marked *