Why does WCF return myObject[] instead of List like I was expecting?

前端 未结 4 585
甜味超标
甜味超标 2020-11-27 03:10

I am returning a List from my WCF method. In my client code, it\'s return type shows as MyObject[]. I have to either use MyObject[], or IList, or IEnumerable...



        
4条回答
  •  情话喂你
    2020-11-27 03:36

    Stever B is correct. WCF tries really hard not to be coupled to .NET. You may want to allow a Java client to connect to your component. Arrays are interoperable. Generic .NET lists aren't.

    However, you're more than welcome to create your own proxy class that will convert the array back into a List or anything else that you'd like. The nice thing about manually creating your own proxies is that you're in complete control of what they do.

提交回复
热议问题