I was wondering if
var list = new List<t>();
exactly the same as
List<t> list = new List<t>()
Is this exactly the same or are there any differences?
I was wondering if
var list = new List<t>();
exactly the same as
List<t> list = new List<t>()
Is this exactly the same or are there any differences?
Yes, this is totally the same. The compiler will internally replace the var
with the actual type, inferred from right side of the expression.
In the C# 9 you can also use another type of record: List<t> list = new()
and compiler will infer the type for the right part from the left one.