Hi All,

I am working on a project that involes reading in an xml and sending out a soap message but have come stuck with an error of Cannot implicitly convert type 'string' to 'string[]'.

The code is:

foreach (var dr in DataRecords)
{
  //build up the values we're interested in

string objtype = dr.Element("FWTIndividualUpdate").Element("BriefDetails").Element("ObjectID").Element("ObjectType").Value;
string objref = dr.Element("FWTIndividualUpdate").Element("BriefDetails").Element("ObjectID").Element("ObjectReference").Value;

fwtIndividualUpdate.BriefDetails.ObjectID.ObjectType = objtype;
fwtIndividualUpdate.BriefDetails.ObjectID.ObjectReference = objref;

     try
     {
       Console.WriteLine("Attempting update individual");
       Console.WriteLine("-----------------------------------------------------------------------------");

       int result = inUpdate.updateIndividual(fwtIndividualUpdate);

       Console.WriteLine("Update successful!");
       Console.WriteLine("-----------------------------------------------------------------------------");
     }

     catch (Exception ex)
     {
       //Obviously this would need more robust error handling
       Console.WriteLine("EXCEPTION CAUGHT Update failed!");
       HandleException(ex);
       Console.WriteLine("-----------------------------------------------------------------------------");
       authenticated = false;
     }

and the error occurs on the odjref

fwtIndividualUpdate.BriefDetails.ObjectID.ObjectReference = objref;

Many thanks

Resolved...

 if (fwtIndividualUpdate.BriefDetails.ObjectID.ObjectReference.Count()>0)
     {
       fwtIndividualUpdate.BriefDetails.ObjectID.ObjectReference[0] = objref;
     }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.