프로그래밍/Unity

Dictionary<TKey, TValue>.ContainsKey메소드

redjam0123 2017. 4. 9. 10:14

Dictionary<TKey, TValue>.ContainsKey메소드

2016.10.19. 17:31

 

[c#]
public bool ContainsKey(
  TKey key
)
 
[c++]
public:
virtual bool ContainsKey(
  TKey key
)
cs

Dictionary<Tkey, TValue>에서 특정키가 있는지 여부를 확인한 결과를 반환한다.
지정된 키가 있으면 true, 아니면 false. 

public class DictionaryEx{
    public static void Main(){
        IDictionary<string, string> openWith = new IDictionary<string, string>();
        if (!openWith.ContainsKey("ht"))
        {
            openWith.Add("ht", "hypertrm.exe");
            Console.WriteLine("Value added for key = \"ht\": {0}", 
                openWith["ht"]);
        }
    }
}
cs