Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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);
Source by www.functionx.com #
 
PREVIOUS NEXT
Tagged: #array #objects
ADD COMMENT
Topic
Name
9+2 =