Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not surprisingly, C# worlds the same way with the only exception that you have to declare the variables as β€œvar” but they are still strongly typed




It's also not quite as easy to declare and build an array. You can't just write

  var arr = [ 1, 2, 3];
You have to write something like

  var arr = new int[] { 1, 2, 3 };
However if you have previously declared `arr` to be of type `int[]` (or another collection type such as `List<int>`), then you can write

  arr = [ 1, 2, 3 ];
I haven't used TypeScript so don't know if it distinguishes between arrays and lists, and if so how it determines one or the other in inferred types. Would be curious to know.

Technically you're also allowed to use anonymously typed objects as inferred generic typed parameters in method calls.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: