0
我使用的排序字符串數組集合的所有的詞典作爲這樣的形式....字典<字符串,字符串[]>無法含蓄轉換類型「串[]」爲「字串」
字典<(關鍵:專題),(價值:字符串數組#File.ReadAllLines(#somepath))>
例子:
public static Dictionary<string, string[]> flags = new Dictionary<string, string[]>()
{
{ "food", new string[] { l_food }};
}
public static string[] l_food = File.ReadAllLine(_path + @"..//..//lists/food.txt");
我的目標是用我的課:
public class Algorithms
{
public static string Main(string message)
{
return Get_Response(Get_Topic(message));
}
private string Get_Topic(string message)
{
string[] words = message.Split(' ');
foreach (string word in words)
{
foreach (KeyValuePair<string, string[]> flag in Responses.flags)
{
if (Responses.ignore.Contains(word) == true) ;
else if (flag.Value.ContainsValue(word) == true && Responses.ignore.Contains(word) == false) return flag.Key;
else if (flag.Value.ContainsValue(word) == false && word == " " || word == null) return "afk";
else return "general";
}
}
return null;
}
private string Get_Response(string topic)
{
switch (topic)
{
case "music":
return Set_Response(Responses.r_music);
case "art":
return Set_Response(Responses.r_art);
case "mathmatics":
return Set_Response(Responses.r_mathmatics);
case "military":
return Set_Response(Responses.r_military);
case "technology":
return Set_Response(Responses.r_technology);
case "science":
return Set_Response(Responses.r_science);
case "religion":
return Set_Response(Responses.r_religion);
case "sex":
return Set_Response(Responses.r_sex);
case "wealth":
return Set_Response(Responses.r_wealth);
case "job":
return Set_Response(Reponses.r_job);
case "games":
return Set_Response(Responses.r_games);
case "food":
return Set_Response(Responses.r_food);
case "politics":
return Set_Response(Responses.r_politics);
case "movie":
return Set_Response(Responses.r_movie);
case "general":
return Set_Response(Responses.r_general);
case "afk":
return Set_Response(Responses.r_afk);
}
}
public string Set_Response(string[] topic)
{
return topic[(int)new Random().Next(topic.Length)];
}
}
...抓住'主題'(即食物)通過匹配字符串數組(從文本文件加載)中不被我的忽略列表中刪除的可能單詞從用戶消息中刪除。
這對於我和亂搞一個聊天機器人的應用程序,但是當我看到這個
錯誤CS0029的問題出現了:無法隱式轉換類型string[]' to
字符串」(CS0029)(SimpleMan)
提個醒這個IDE是MonoDevelop的,因爲我的筆記本電腦是一個蹩腳的2003 Linux機器......
我真的不知道......