I have a text file which contains bunch of teams, and stadiums. It can easily be added into a list or a dictionary. I have a software that fetches data from a website. If for example, when it gets the "Team1" value which let's say is "Arsenal" and i have already "Arsenal" in the dictionary and its key is the stadium value of it, how do i make a condition to check "If the Team1 value that was received is "xxxxx", search for it in the dictionary/list whatever, and find it's k value?
You are looking to get value from Dictionary,only if Key Exists.Dictionary has ContainsKey method,
//dict is a dictionary
if(dict.ContainsKey("Arsenal")) {
Console.WriteLine(dict[Arsenal]); //will return stadium value
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.