WARNING #1042

    Array 1% may need to have individual elements initialized.

    Description

    This EWI is caused when a fixed-size array is declared in Visual Basic 6. This EWI is emitted to indicate a possible difference between .NET and Visual Basic 6 when handling types that map to structs in arrays.

    Recommendations

    As of VBUC version 2.2 this EWI can be disregarded as the ArrayHelper class will handle initialization. In previous versions it might be necessary to review each instance of this EWI and verify that the migrated code is functionally equivalent.

    Sample VB6 

    Private m_Rates(50) As InterestRateTypes

    Target VB.NET 

    'UPGRADE_WARNING: (1042) Array m_Rates may need to have individual elements initialized.

    Private m_Rates() As InterestRateTypes = ArraysHelper.InitializeArray(Of InterestRateTypes())(NewInteger(){51})

    Expected VB.NET 

    Undetermined expected code, final resolution will vary on each case. Though in the provided example, there is no need to provide any additional initialization beyond what the VBUC has included. Also take note of Visual Basic: How to: Initialize an Array Variable.

    Target C# 

    //UPGRADE_WARNING: (1042) Array m_Rates may need to have individual elements initialized.

    staticprivateInterestRateTypes[] m_Rates = ArraysHelper.InitializeArray<InterestRateTypes[]>(newint[]{51});

    Expected C# 

    Undetermined expected code, final resolution will vary on each case. Though in the provided example, there is no need to provide any additional initialization beyond what the VBUC has included.


    Download VBUC Free Trial
    Download VBUC Now

    It's time to eradicate VB6
    ROI of eradicating VB6

    8 Proven Tips for
    Planning a Successful Migration

    8 Tips for migration