views:

130

answers:

1

Hi,

I am want to serialize and array object for a custom wizard I am writing but I am having difficulties doing this. Can someone help this is the error and code snippets I am using.

The error I believe has to do with not being able to convert the array.

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  A: 

the function

public WizardBase CreateWizardArray(Wizards wizards)

is returning the local variable b, which is declared as WizardBase[], not WizardBase

as far as i can see, there is no serialization going on here at all, the function should just be

public WizardBase [] CreateWizardArray(Wizards wizards)

I would also point out that the function doesn't really do anything terribly useful, it merely copies the elements of a List to an Array (by reference)...

Steven A. Lowe