可以尝试将if语句中的ContainsValue方法改为Contains方法,同时将FirstOrDefault方法中的Value改为Key,如下所示:

private string GetNextState(string item, Dictionary<string, List> gotos) { string[] items = item.Split(' '); string nextState = ""; foreach (string i in items) { if (!i.Contains(".")) { nextState += i + " "; } } if (gotos.ContainsKey(nextState.Trim())) { return gotos.FirstOrDefault(x => x.Key == nextState.Trim()).Key; } else { return gotos.Count.ToString(); } }

这样就可以解决参数类型错误的问题

private string GetNextStatestring item Dictionarystring Liststring gotos string items = itemSplit ; string nextState = ; foreach string i in items

原文地址: http://www.cveoy.top/t/topic/he8Y 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录