增强配置文件提供程序

时间:2008-10-24 06:22:48

标签: c# arrays serialization profile

我想为我正在编写的自定义向导序列化和数组对象但是我在执行此操作时遇到了困难。有人可以帮助这是我正在使用的错误和代码片段。

我认为错误与无法转换数组有关。

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\

1 个答案:

答案 0 :(得分:1)

功能:

public WizardBase CreateWizardArray(Wizards wizards)

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

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

public WizardBase [] CreateWizardArray(Wizards wizards)

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