2

私は次のようなクラスを持っています:

public class CompanyData
    {
        # region Properties
        /// <summary>
        /// string CompanyNumber
        /// </summary>
        private string strCompanyNumber;    

        /// <summary>
        /// string CompanyName
        /// </summary>
        private string strCompanyName;

    [Info("companynumber")]
    public string CompanyNumber
    {
        get
        {
            return this.strCompanyNumber;
        }

        set
        {
            this.strCompanyNumber = value;
        }
    }

    /// <summary>
    /// Gets or sets CompanyName
    /// </summary>
    [Info("companyName")]
    public string CompanyName
    {
        get
        {
            return this.strCompanyName;
        }

        set
        {
            this.strCompanyName = value;
        }
    }

    /// <summary>
    /// Initializes a new instance of the CompanyData class
    /// </summary>
    public CompanyData()
    {
    }

    /// <summary>
    /// Initializes a new instance of the CompanyData class 
    /// </summary>
    /// <param name="other"> object company data</param>
    public CompanyData(CompanyData other)
    {
        this.Init(other);
    }

    /// <summary>
    /// sets the Company data attributes
    /// </summary>
    /// <param name="other">object company data</param>
    protected void Init(CompanyData other)
    {
        this.CompanyNumber = other.CompanyNumber;
        this.CompanyName = other.CompanyName;
    }

    /// <summary>
    /// Getting array of entity properties
    /// </summary>
    /// <returns>An array of PropertyInformation</returns>
    public PropertyInfo[] GetEntityProperties()
    {
        PropertyInfo[] thisPropertyInfo;

        thisPropertyInfo = this.GetType().GetProperties();

        return thisPropertyInfo;
    }

    }

csv ファイルが読み取られ、CompanyData オブジェクトのコレクションが作成されます

このメソッドでは、プロパティと値を取得しようとしています:

private void GetPropertiesAndValues(List<CompanyData> resList)
{

        foreach (CompanyData resRow in resList)
        {

            this.getProperties = resRow.ExternalSyncEntity.GetEntityProperties();

            this.getValues = resRow.ExternalSyncEntity.GetEntityValue(resRow.ExternalSyncEntity);

         }
 }

ここに問題があります。最初のオブジェクトの場合、は配列の最初の要素として をGetEntityProperties()返します。CompanyNumber残りのオブジェクトについてはCompanyName、最初の要素として返されます。

配列が一貫していないのはなぜですか?

よろしく。

4

1 に答える 1