How to declare an integer type variable in C#?

Asked

Viewed 337 times

4

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

How do I declare an integer type variable?

  • 4

    Hello, Watson William, sir. I made a slight adjustment to your post, because your name already appears under the text, and anyway, it will be read at various times and by several people. The time you have a little time, you can access the [Tour], the [Help] and [Ask] to get some tips and references for better use of the site. Welcome.

  • Related, int and Integer - Java, I know it’s java, but the semantics are the same.

  • Did the answer solve your problem? Do you think you can accept it now? See [tour] to understand how it works. It would be helpful to indicate to everyone that the solution was useful and satisfactory for you. You can also vote on any question or answer you find useful on the entire site

1 answer

13

Just declare the guy before her 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

I put in the Github for future reference.

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

About the terms used.

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

What is the difference between declaration and definition?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.