0
我有这个需要识别具有模式符号的产品列表。到目前为止,下面是我用来识别它们的代码。不幸的是,当我调试程序时,它不识别模式。识别产品名称中是否存在符号
string[] patterns = new string[] { "." ,",", ";", "'", "`", ":", "/", "\\", "*", "|" ,"(", ")","[", "]", "{", "}", "<", ">" };
List<Product> products = new List<Product>
{
new Product { ID = 1, Name = "Jenny's Product", Price = 10 },
new Product { ID = 2, Name = "Brunus C.O.", Price = 10 },
new Product { ID = 3, Name = "GreenCross", Price = 10 },
};
foreach (var item in products)
{
if (patterns.Contains(item.Name))
{
Console.WriteLine(item.Name);
}
}
Console.ReadLine();
谢谢!你帮了我 – Chris 2015-04-06 06:03:10