Hello World

Declaring Variables

Variables are declared by typing the variable type and then a name. For example,

int number;

This would declare an integer with the the variable name "number".

You can also give this variable a value in the declaration by adding "= value". For example,

int number = 10;

Variables can be changed in a similar way, but you need not redeclare the variable.

number = 11;

There are a potentially infinite number of variable types when you get on to classes, but for generally programming you have;

//number based variable types
short
byte
int
float
double
 
//others
string
bool
Random

Writing to Screen

The "System" header file gives a lot of methods you can use to interact with the console. The 2 main ones for writing to the console screen are:

Console.Write("Text here"); //Write a line of text
Console.WriteLine("Text here"); //Write a line of text with a line break at the end

To manually insert line breaks you can simply use \n.

//Output:
//    Hello
//    World
 
Console.Write("Hello\nWorld");
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.