Quantcast
Channel: CSDN博客移动开发推荐文章
Viewing all articles
Browse latest Browse all 5930

.NET-IList和List的Reverse陷阱

$
0
0

.NET提供的集合命名空间中,有个常用的列表list 这个数据结构,在使用过程中,遇到了一个陷阱,也是暂时没想明白的问题,在这里备忘一下。

请看下面测试

IList<int> rtn2 = new List<int>() {0, 4, 9};
            rtn2.Reverse();

上面执行反转后,rtn2的顺序未发生任何变动。

只能将rtn2声明为List<int> 才能执行反转。

作者:daigualu 发表于2017/4/19 14:04:57 原文链接
阅读:187 评论:0 查看评论

Viewing all articles
Browse latest Browse all 5930

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>