Title here
Summary here
Go supports constants of character, string, boolean, and numeric values.
const
declares a constant value.
Module ConstantsExample
Const s As String = "constant"
Sub Main()
Console.WriteLine(s)
' A const statement can appear anywhere a var statement can.
Const n As Integer = 500000000
' Constant expressions perform arithmetic with arbitrary precision.
Const d As Double = 3e20 / n
Console.WriteLine(d)
' A numeric constant has no type until it’s given one, such as by an explicit conversion.
Console.WriteLine(CLng(d))
' A number can be given a type by using it in a context that requires one, such as a variable
' assignment or function call. For example, Math.Sin expects a Double.
Console.WriteLine(Math.Sin(n))
End Sub
End Module
To run the program, put the code in a file named ConstantsExample.vb
and use the following commands to compile and run it.
vbc ConstantsExample.vb
ConstantsExample.exe
Here is the expected output:
constant
6E+11
600000000000
-0.28470407323754404
Now that we can run and build basic Visual Basic .NET programs, let’s learn more about the language.