Brian
Brian

Reputation: 5049

Cannot implicitly convert type 'String' to 'string' in C#

Yes, you read the title correctly. 'string' to 'String'. Not an array of strings. Just string.

I finally figured this out after coming back and forth to it. No matter what I tried, I could not do this. 'string' was no longer an alias for 'String'. I thought I was in some sort of nightmare dream.

I thought things through thoroughly, and finally realized that the issue was with a generated proxy class from wsdl.exe. For some reason, the WSDL specified a definition for 'String'. Since the generation was sans-namespace, this overrode System.String.

Upvotes: 0

Views: 117

Answers (1)

Brian
Brian

Reputation: 5049

The solution was simply to provide a namespace:

namespace myNamespace
{
...code here...
}

I hope this is helpful to someone out there at some point. I found it impossible to retrieve any results when first Googling for it. It would have saved me hours if I had found this.

Also, please forgive me if this is not appropriate to do. Just message me and I will remove it. I did read that it is OK to post and answer a question to help others, but since I don't have 15 reps, I can't choose the option to do so "officially."

Upvotes: 1

Related Questions