0

Does var y = 15; not automatically declare y as an int?

Hi, I'm new to C#. The SoloLearn question is: Fill in the blanks to declare two variables of type int and display their sum to the screen. int x = 8; __ y = 15; Console.WriteLine(x _ y); So I know int y = 15 and x + y will work, but using var y = 15 also gives you 23 and wont y then also be declared as an int?

2nd Sep 2019, 2:50 PM
Nico van der Merwe
Nico van der Merwe - avatar
2 odpowiedzi
+ 2
It does work but sololearn expects int as answer I think
2nd Sep 2019, 3:04 PM
HNNX 🐿
HNNX 🐿 - avatar
+ 1
int x = 8; int y = 15; Console.WriteLine(x + y);
30th Dec 2021, 4:11 PM
maxmudov abubakr