C# – Why c# treats 0 as int and not as short/decimal etc

c++

In c# when i say :

var s = 0;

what should be type of s ? it makes it int32. then seems like var is not usable for types like short and others(?).

Best Solution

Look at this post here at StackOverflow.

You can specify a postfix for all numbers.

var i = 0;
var d = 0d;
var f = 0f;
var l = 0L;
var m = 0m;