コード例 #1
0
ファイル: Program.cs プロジェクト: rmdouglas/Data.HList
        static void HDictExampe()
        {
            var hd =
                new HDict <RelationIS>()
                .Add(1, "foo")
                .Add("bar", 1);
            // compile error!
            //hd.Add(1, 1);
            string foo;

            if (hd.TryGetValue(1, out foo))
            {
                Console.WriteLine(foo);
            }
            int bar;

            if (hd.TryGetValue("bar", out bar))
            {
                Console.WriteLine(bar);
            }
            int buz;

            if (hd.TryGetValue("buz", out buz) == false)
            {
                Console.WriteLine("buz does not found!");
            }
        }
コード例 #2
0
        public T HGet <T>(string hashId, string key)
        {
            Dict hValue;

            if (HData.TryGetValue(hashId, out hValue))
            {
                CacheValue val = null;
                if (hValue.TryGetValue(key, out val))
                {
                    return(val.GetObject <T>());
                }
            }
            return(default(T));
        }