`
huhu_long
  • 浏览: 73509 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

StringOfArray in web service proxy

    博客分类:
  • .net
阅读更多
Sometimes we may need reference web service hosted base on java platform. And you are very likely to generate proxy classes with class type "ArrayOf***". So we may have to convert these types to collection or other appropriate type in our own application, and our types to "ArrayOf***".

Here is a sample to convert string[] to ArrayOfString

public class ArrayOfString : System.Collections.Generic.List<string>
{
}

private static T To<T>(IEnumerable<string> strings) where T : IList<string>, new()
{
    if (strings == null) return default(T);

    var tResult = new T();
    foreach (var s in strings) tResult.Add(s);
    return tResult;
}

var strings = new string[] {"aaa", "BBB", "ccc", "DDD"};

var arrayOfString = To<ArrayOfString>(strings);
分享到:
评论
3 楼 z169351998 2013-01-11  
2 楼 z169351998 2013-01-11  
撒大大 [size=x-small][/size]
1 楼 z169351998 2013-01-11  
     
引用
[url][/url][flash=200,200][/flash]
[size=x-small][/size][align=center][/align]阿迪was

相关推荐

Global site tag (gtag.js) - Google Analytics