I have an error "Cannot implicitly convert type "CorrespondingBall.MyCloudService.ArrayOfString' to 'System.Collections.Generic.List". Does anyone know how can I solved it? I have read up on Convert array of strings to List<string>, but I do not understand and implement it. My codes are below.
ServiceSoapClient client = new ServiceSoapClient();
List<string> objectiveList = new List<string>();
client.getObjectiveCompleted += new EventHandler<getObjectiveCompletedEventArgs>(getObjectiveCompletedHandler);
client.getObjectiveAsync();
I received the error for
private void getObjectiveCompletedHandler(object sender, getObjectiveCompletedEventArgs e)
{
objectiveList = e.Result;
}
If ArrayOfString is truly a basic array of string types, you can do the following:
string[] names = { "John", "Doe" };
List<string> namesList = new List<string>(names);
// OR
List<string> namesList2 = new List<string>();
foreach (string name in names)
{
namesList2.Add(name);
}
Supposing e.Result is an array of string you can do it like this
private void getObjectiveCompletedHandler(object sender, getObjectiveCompletedEventArgs e)
{
List<string> namesList = new List<string>();
foreach (string name in e.Result)
{
namesList.Add(name);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With