我有一个带有巨大两列表的word文档,第一列包含一个代码,第二列包含一个单词。在许多行中,第二列的单词重复,因此我需要使用重复的单词找到所有行。我正在使用findAll()方法并为每个出现的单词获取索引但我无法从该索引获取表行。 以下是我正在使用的代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebApplication3.Models
{
public class Calculations
{
public static int Add(params int[] numbers)
{
var sum = 0;
foreach (var n in numbers)
{
sum += n;
}
return sum;
}
public static int Subtract(params int[] numbers)
{
var sum = 0;
foreach (var n in numbers)
{
sum -= n;
}
return sum;
}
public static int Multiply(params int[] numbers)
{
var sum = 0;
foreach (var n in numbers)
{
sum *= n;
}
return sum;
}
public static int Divide(params int[] numbers)
{
var sum = 0;
foreach (var n in numbers)
{
sum /= n;
}
return sum;
}
public static string[] CheckingOfSomeSort(string userInput, int value, bool isAddition, bool isSubtraction, bool isDivision, bool isMultiplication)
{
if (userInput.Contains("+"))
{
var addition = userInput.Split('+');
value = 1;
isAddition = true;
return addition;
}
else if (userInput.Contains("-"))
{
var subtraction = userInput.Split('-');
value = 2;
isSubtraction = true;
return subtraction;
}
else if (userInput.Contains("*"))
{
var multiplication = userInput.Split('*');
value = 3;
isMultiplication = true;
return multiplication;
}
else if (userInput.Contains("/"))
{
var division = userInput.Split('/');
value = 4;
isDivision = true;
return division;
}
return null;
}
}
}
答案 0 :(得分:0)
您可以将LinQ用于获取重复行:
var repetitive = doc.Tables.GroupBy(s => s.Word).SelectMany(grp => grp.Skip(1));
注意: - 此处Word
是第二列