Answers for "c# array of objects"

C#
1

c# array of objects

T[] InitializeArray<T>(int length) where T : new() {
    T[] array = new T[length];
    for (int i = 0; i < length; ++i) {
        array[i] = new T();
    }
    return array;
}

// Usage:
MyObjects[] my_objects = InitializeArray<MyObjects>(10);
Posted by: Guest on March-19-2021

Code answers related to "c# array of objects"

C# Answers by Framework

Browse Popular Code Answers by Language