How to declare an integer variable in C #?

3

I'm learning C # to migrate a system in VBA to C #. I'm really enjoying the .Net language.

How do I declare a variable of integer type?

    
asked by anonymous 30.06.2016 / 23:41

1 answer

10

Just declare the type before its name:

int x; //declarando sem inicializar. Será inicializado implicitamente com 0
var y = 1; //usando inferência de tipo. Só funciona em variáveis locais
int z = 2; //definição (declaração+atribuição) explícita

The so-called built-in types of the language can be seen in this table . Contrary to what many think C # do not have so-called "primitive" types. These listings are those that language provides some extra facility for their use and recognition.

About terms used .

C # is the language, .Net is the platform .

What's the difference between statement and definition?

    
30.06.2016 / 23:45