Var And Var! In Microsoft Bosque Programming Language
All programming languages have one central area that is used to declare the variables. In this article, we are going to learn how to declare a variable in Bosque programming.
- var
- var!
- var statement is used to declare a const variable
- var! is used to declare a non-const variable.
var variable
- var Identifier = exp;
- var identifier : Datatype = exp;
The example declaration code is given below.
- var x:Int = 3; // variable declare as int and initialized.
- var x =” Hello World”; // variable introduced and inferred to be of type string
Once a variable has initialized, it can't be changed at a later point. In the below sample code, a variable is initialized as “Hello World” and is later changed to “Welcome Bosque.”
- namespace NSMain;
- entrypoint
- function main(): String {
- var x2 = "Hello World";
- x2 = "Welcome bosque";
- return x2;
- }
Compile the program. The Bosque compiler throws a parse error “variable defined as const.”

var! variable
In the case of var! the syntax can be modified by assignment statements. We can declare the var! variable in three different types. Two types are the same as var declaration while the third one is only a datatype declaration without initialization.
- var !identifier: Type;
- var !Identifier = exp;
- var !identifier: Datatype = exp;
Below is the sample code using var!




Sarathlal SaseendranPosted May 18, 2019, 3:12 PM
Something different and interesting Vinoth. Thanks for sharing.
Mahesh ChandPosted May 18, 2019, 7:17 AM
Nice Vinod. You may want to put links to your previous article for someone who finds this article. Cheers!