2
我已將顯示器放入我的程序中,並且可以清楚地看到正在搜索的字符串存在。string []。即使文本在數組中,也不會找到匹配項
有可能有'隱形'字符阻止它的工作?
var items = new List<string>(currComponent.Split(new string[]
{ "\r\n", "\n" }, StringSplitOptions.None));
string feedback = string.Empty;
foreach (string i in items)
{
feedback += i + ". ";
}
ScriptingObject.WriteLogMessage
("feedback:" + feedback + "<EOF>", true);
if (items.Contains(attributeDescription))
顯示的結果表明,該變量反饋包含短語「煙道」, 但items.Contains("Flue")
沒有找到它。
Message: Status message: 2015-01-09 10:36:18 | feedback:_ ,. Boiler Flue Type.
Boiler make. Boiler Model. Gas Appliance Safety Protector. __.. . <EOF>
Next message: unable to process an Update Location record ...because of error:
item Flue not found .
謝謝。這是正確的答案。 –
我仍然遇到這個問題,它沒有找到文本,它顯然寫入日誌。相關數據來自Screen Grab。它可能包含不可見或不可打印的字符,這會阻止.contains正常工作? –
對於像「Boiler」和System.String一樣的_plain ASCII words_(!!!)我無法考慮任何字符編碼問題。嘗試發佈你的新代碼... –