小编G1x*_*b17的帖子

C#Union vs包含连续数据列表

我在查找一些问题的答案时遇到了一些麻烦,我已经解决了一些特定于我正在处理的代码的问题,而且我似乎无法找到关于Union如何在C#中使用它的核心机制的文档.所以问题是这个.

我有一组与此示例类似的数据:

     object[] someMainTypeArray = new object [n];
     List<object> objList2 = new List<object>();
     foreach ( object obj in someMainTypeArray ) {
        List<object> objList1 = new List<object>() { "1","2","3" };
        //each obj has a property that will generate a list of data
        //objList1 is the result of the data specific to obj
        //some of this data could be duplicates
        //Which is better, this:
        foreach ( object test in objList1 ) {
           if ( !objList2.Contains( test ) ) {
              objList2.Add( test ); …
Run Code Online (Sandbox Code Playgroud)

c# contains unions

5
推荐指数
1
解决办法
335
查看次数

标签 统计

c# ×1

contains ×1

unions ×1