我自己正在学习Dotnet c#。如何查找给定文本是否存在于字符串中,如果存在,则如何查找单词在该字符串中重复的次数。即使这个单词拼错了,如何找到它并打印出拼写错误的单词呢?我们可以使用c#中的集合或linq来实现这一点,但是在这里,我使用string类并使用collections方法,但在此之后,iam触发了。
如果我们能在linq的帮助下做到这一点,怎么做?因为linq可以处理集合,对吗?你需要一个列表才能和linq一起玩。但现在我们在玩弦乐(段落)。如何使用linq在段落中找到一个单词?帮帮忙吧。
以下是我迄今所尝试过的。
string str = "Education is a ray of light in the darkness. It certainly is a hope for a good life. Eudcation is a basic right of every Human on this Planet. To deny this right is evil. Uneducated youth is the worst thing for Humanity. Above all, the governments of all countries must ensure to spread Education";
for(int i = 0; i < i++)
if (str.Contains("Education") == true)
{
Console.WriteLine("found");
}
else
{
Console.WriteLine("not found");
}https://stackoverflow.com/questions/73425125
复制相似问题