Cannot implicitly convert type... to ArrayOfStrings RRS feed

  • Question

  • Problem:

    I have consumed a WSDL

    One of the values is type: tns: ArrayOfStrings

    How do I write to it please ?

    Whatever I do, I get “Cannot implicitly convert type… to ArrayOfStrings”

    I tried the following:


    Same error all the time: Cannot implicitly convert….

    Question: How do I write to array of strings in this scenario ???

    Thursday, October 26, 2017 10:54 AM

All replies

  • You used a service reference then :} When the svcutil tool runs against a WSDL that returns a generic array type it converts it to a strongly typed class (ArrayOfStrings in your case). You should be able to create an instance of this type directly but it has been a long time since I've had to do that so I don't remember the exact code. Take a look at the definition of ArrayOfStrings to identify what methods are available to you.

    string[] tLabel = new [] { "tl" };
    string[] createText = new [] { "Hello", "And", "Welcome" };
    //I think this should work
    scm.trackLabel = tLabel;
    //But if trackLabel is ArrayOfStrings then you'd do something like this
    scm.trackLabel = new ArrayOfStrings();
    //Cannot remember how to get the elements into the array though...

    Michael Taylor

    Thursday, October 26, 2017 2:10 PM