Initializing a C# array with multiple copies of the same element

后端 未结 5 1859

In the C++ Standard Template Library (STL), it is possible for example to create a vector consisting of multiple copies of the same element, using this constructor:

5条回答
  •  误落风尘
    2021-01-07 18:08

    In VB.NET

    Imports System.Linq

    Dim n As Integer = 10
    
    Dim colorArray = New Color(n - 1) {}.[Select](Function(item) Color.White).ToArray()
    

提交回复
热议问题