가 등과 같은:
public class cls_words : IEquatable<cls_words>
{
public int indx { get; set; }
public string wordTxt { get; set; }
public int wordIsFound { get; set; }
public override string ToString()
{
return "ID: " + wordIsFound + " Name: " + wordTxt;
}
public override bool Equals(object obj)
{
if (obj == null) return false;
cls_words objAsWord = obj as cls_words;
if (objAsWord == null) return false;
else return Equals(objAsWord);
}
public override int GetHashCode()
{
return wordIsFound;
}
public bool Equals(cls_words other)
{
if (other == null) return false;
return (this.wordIsFound.Equals(other.wordIsFound));
}
}
기본적으로 클래스는 단어가 있는지 여부와 상관없이에서 발견되었습니다.
그래서 내가 목록을 만들은 이 클래스의 이와 같:
List<cls_words> wordsIn = new List<cls_words>();
wordsIn.Add(new cls_words { indx= 1, wordTxt = "test", wordIsFound=0 });
wordsIn.Add(new cls_words { indx= 2, wordTxt = "the", wordIsFound=0 });
wordsIn.Add(new cls_words { indx= 3, wordTxt = "test", wordIsFound=0 });
그 때 나는 검색 목록이 포함된 경우는 단어,나는 설정하려는 모든 wordIsFound 값을 1 고 있습니다. 어떤 단어 목록에서도 동일합니다.
그래서 뭔가
string wordSearch = "test";
if (wordsIn.Exists(x => x.wordTxt == wordSearch)) {
//set all wordIsFound = 1 where word matches wordSearch
}
그래서 내가 어떻게 설정 wordIsFound1 에서 1,제 3 항목(목록에서 일치하는 사람을 익?