C # declare a variable,
It is easy to declare a variable in the C # program.
As shown below, declare a variable and assign a value:
Int type = 22; Console. writeLine (type); bool type1 = false; Console. writeLine (type1); string type2 = "Insus. NET "; Console. writeLine (type2); double type3 = 4.8; Console. writeLine (type3); Source Code
Run and output the result on the console:
When declaring a variable, we can use the var Keyword:
Var type = 22; Console. writeLine (type); var type1 = false; Console. writeLine (type1); var type2 = "Insus. NET "; Console. writeLine (type2); var type3 = 4.8; Console. writeLine (type3); Source Code
In later versions of C #, you can also use the dynamic keyword to declare the variable as a dynamic variable:
Dynamic type; type = 22; Console. writeLine (type); type = false; Console. writeLine (type); type = "Insus. NET "; Console. writeLine (type); type = 4.8; Console. writeLine (type); Source Code