0

作成しているカスタムウィザードのオブジェクトをシリアル化して配列したいのですが、これを行うのに問題があります。誰かがこれを手伝ってもらえますか?これは私が使用しているエラーとコードスニペットです。

私が信じるエラーは、配列を変換できないことに関係しています。

namespace Helios.Web.Framework
{
    /// <summary>
    /// Summary description for GlobalWizardMethods
    /// </summary>
    public class GlobalWizardsLibrary : Wizards
    {
        public GlobalWizardsLibrary() { }
        public WizardBase CreateWizardArray(Wizards wizards)
        {
            WizardBase[] b = new WizardBase[wizards.IListWizardBase.Count];
            for (int i = 0; i < b.Length; i++)
            {
                b[i] = (WizardBase)wizards.IListWizardBase[i];
            }
            return b;
        }
    }
}

-

        wizards = new Wizards();
        wizards.IListWizardBase = new List<WizardBase>();

        //if (wizards.WizardBase[0] == null)
        //{
            clientTakeOnWizardInfo = new ClientTakeOnWizardInfo();

            //Create any preset data to identify the client and wizard.
            CreatePresetWizardInfo();

            //Instantiate a new instance of the clientTakeOnWizard.organisationDetails.
            clientTakeOnWizardInfo.organisationDetails = new OrganisationDetails();

            //We update the Organisation Details with the new values from the form.
            clientTakeOnWizardInfo.organisationDetails.Guid = Profile.Wizards.WizardId.ToString();
            clientTakeOnWizardInfo.organisationDetails.OrganisationName = this.OrganisationName.Text;
            clientTakeOnWizardInfo.organisationDetails.PayrollSystem = this.PayrollSystem.SelectedValue;
            clientTakeOnWizardInfo.organisationDetails.Region = this.Region.SelectedValue;
            clientTakeOnWizardInfo.organisationDetails.RegistrationNumber = this.RegistrationNumber.Text;

            //Profile.Wizards.WizardData = clientTakeOnWizardInfo;

            Profile.Wizards.WizardStep = wizardClientTakeOnWizard.ActiveStepIndex;

            wizards.IListWizardBase.Add(clientTakeOnWizardInfo);
            GlobalWizardsLibrary s = new GlobalWizardsLibrary();
            s.CreateWizardArray(wizards);

Error 16 Cannot implicitly convert type 
    'Helios.Web.Framework.WizardBase[]' to 
    'Helios.Web.Framework.WizardBase'
    C:\...\GlobalWizardsLibrary.cs  34  20  
C:\...\HeliosWeb\
4

1 に答える 1

1

関数:

public WizardBase CreateWizardArray(Wizards wizards)

WizardBase[]...ではなくとして宣言されているローカル変数 b を返しますWizardBase

私が見る限り、ここでは連載はまったく行われていません。関数は次のようにする必要があります。

public WizardBase [] CreateWizardArray(Wizards wizards)

私はまた、この関数は実際には何もひどく有用ではないことを指摘したいと思います.Listの要素をArrayに(参照によって)コピーするだけです...

于 2008-10-24T07:31:01.403 に答える