如何搜索以某个值开头的字符串?

How to search for a string beginning with a certain value?

我正在搜索数组并试图找到对象描述。我遇到的问题是尝试使用通配符。如何在数组中搜索以 "Description:".

开头的值
int[] poss = textlist.Select((b, i) => b == "Description:*" ? i : -1).Where(i => i != -1).ToArray();

string[] Description = new string[poss.Length - 1];

foreach (int pos in poss)
{
    Description = textlist[pos];
}
int[] poss = textlist.Select((b, i) => 
    b.StartsWith("Description") ? i : -1).Where(i => i != -1).ToArray();

你可以这样做:

Description = textlist.Where(s => s.StartsWith("Description:")).ToArray();