Linq 如何使用c查找数组中记录的位置#

Linq 如何使用c查找数组中记录的位置#,linq,lambda,Linq,Lambda,我有一系列的元素和记录。我想显示数组中只包含记录的所有记录 例如: 数组包含:[1,2,3] 记录包括:[1,2,3,4,5,6,7,8,9,10] 我只想显示1,2,3记录。如何在c中进行比较# 对不起我的英语 假设您使用linq进行查询: int[] array = new[] { 1,2,3 }; var record1 = new[] { 1,2,3,4,5,6,7,8,9,10 }; var record2 = new[] { 4,5,6,7,8,9,10 }; var records

我有一系列的元素和记录。我想显示数组中只包含记录的所有记录

例如:

数组包含:
[1,2,3]
记录包括:
[1,2,3,4,5,6,7,8,9,10]

我只想显示
1,2,3
记录。如何在c中进行比较#


对不起我的英语

假设您使用linq进行查询:

int[] array = new[] { 1,2,3 };
var record1 = new[] { 1,2,3,4,5,6,7,8,9,10 };
var record2 = new[] { 4,5,6,7,8,9,10 };
var records = new[] { record1, record2 };

// this will return record if at least one record in array is matched
var result1 = from r in records where array.Any(a => r.Contains(a)) select r;

// this will return record only if all items in array are matched
var result2 = from r in records where array.All(a => r.Contains(a)) select r;
string[]a={“1”、“2”、“3”};
字符串[]b={“1”、“2”、“3”、“4”、“1”、“5”、“6”、“7”、“8”、“9”、“10”};
列表x=新列表();
foreach(a中的字符串s)
{
如果(b)包含(s))
{
//如果你只想展示
控制台。写入线(s);
//如果要存储,请将其添加到列表中
如果(!x.Contains)
x、 添加(s);
}
}

你说的“不使用C”是什么意思?你想看另一种语言的代码吗?他忘了在“毫无疑问”后面加逗号:)@Zia-yah我忘了
 string[] a={"1","2","3"};
    string[] b={"1","2","3","4","1","5","6","7","8","9","10"};
    List<string> x=new List<string>();
    foreach (string s in a)
    {
        if (b.Contains(s))
        {
            //if you only wants to display
            Console.WriteLine(s);
            // if you want it to store , add it to a list
            if(!x.Contains(s))
            x.Add(s);
        }
    }