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)

...正在返回局部变量 b,它被声明为WizardBase[],而不是WizardBase

据我所知,这里根本没有进行序列化。该功能应该是:

public WizardBase [] CreateWizardArray(Wizards wizards)

我还要指出,该函数并没有真正做任何非常有用的事情,它只是将 List 的元素复制到 Array (通过引用)......

于 2008-10-24T07:31:01.403 回答