【发布时间】:2022-11-21 08:19:27
【问题描述】:
我想在 | 之后找到字符并在 C# 中检查循环。
就像我有Test|T1。在管道之后,字符可以是Test|T2 或Test|T3 之类的任何东西。
第一个值是Table|Y,第二个值可以是Test|T1、Test|T2或Test|T3。
所以我想在 else 块中检查 | 之后的字符。
foreach (var testing in TestQuestion.Split(','))
{
if(testing.Equals("Table|Y"))
{
order.OrderProperties.Add(new OrderProperty("A")
{
...
});
}
else
{
//check the value after "|"
}
}
所以我想在 else 块中检查 | 之后的字符。
【问题讨论】:
-
string.Split('|')? -
@stuartd,如果我将字符串拆分为
string.Split('|'),那么我只会得到Test。我需要|之后的字符,例如T1、T2或T3。
标签: c#