Direct array initialization with a constant value

前端 未结 6 1441
心在旅途
心在旅途 2020-12-09 14:44

Whenever you allocate a new array in C# with

new T[length]

the array entries are set to the default of T. That is null for th

6条回答
  •  醉梦人生
    2020-12-09 14:54

    If you buy into Arrays considered somewhat harmful, then your question would be moot as you would write:

    var myArray = new List(Enumerable.Repeat(-1, 100));
    

提交回复
热议问题