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

.NET supports this because [Visual] Basic supports it. This can be used from C# - and other languages - but there is no nice syntax supporting it.

  // This also supports multidimensional arrays, that is why the parameters are arrays.
  var array = Array.CreateInstance(elementType: typeof(Int32), lengths: [ 5 ], lowerBounds: [ -2 ]);

  // This does not compile, the type is Int32[*], not Int32[].
  // Console.WriteLine(array[0]);

  array.SetValue(value: 42, index: -2);

  Console.WriteLine(array.GetValue(-2));




TIL thanks!



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: