当前位置: 首页>>代码示例>>C#>>正文


C# Dictionary.GetType方法代码示例

本文整理汇总了C#中System.Collections.Dictionary.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.GetType方法的具体用法?C# Dictionary.GetType怎么用?C# Dictionary.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.Dictionary的用法示例。


在下文中一共展示了Dictionary.GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateTryGetValueDelegateWrapsGenericObjectDictionaries

        public void CreateTryGetValueDelegateWrapsGenericObjectDictionaries() {
            // Arrange
            object dictionary = new Dictionary<object, int>(){
                { "theKey", 42 }
            };

            // Act
            TryGetValueDelegate d = TypeHelpers.CreateTryGetValueDelegate(dictionary.GetType());

            object value;
            bool found = d(dictionary, "theKey", out value);

            // Assert
            Assert.IsTrue(found);
            Assert.AreEqual(42, value);
        }
开发者ID:Marceli,项目名称:JQueryGridTest,代码行数:16,代码来源:TypeHelpersTest.cs

示例2: IsGenericInterfaceAssignableFrom_ReturnsFalseOnIsAssignableForUnimplementedInterface

 public void IsGenericInterfaceAssignableFrom_ReturnsFalseOnIsAssignableForUnimplementedInterface()
 {
     Dictionary<int, int> dictionary = new Dictionary<int, int>();
     Assert.Equal(false, typeof(IList<>).IsGenericInterfaceAssignableFrom(dictionary.GetType()));
 }
开发者ID:corkupine,项目名称:EqualityComparer,代码行数:5,代码来源:TypeExtensionsTest.cs

示例3: GetGenericInterfaceTypeParameters_ThrowsOnUnimplementedInterface

 public void GetGenericInterfaceTypeParameters_ThrowsOnUnimplementedInterface()
 {
     Dictionary<int, int> dictionary = new Dictionary<int, int>();
     Assert.Throws<ArgumentException>(() => typeof(IList<>).GetGenericInterfaceTypeParameters(dictionary.GetType()));
 }
开发者ID:corkupine,项目名称:EqualityComparer,代码行数:5,代码来源:TypeExtensionsTest.cs

示例4: TestCacheableMethodPocoVoidTimed

        public void TestCacheableMethodPocoVoidTimed()
        {


            var tValue = new Dictionary<object, object>();

            var tCachedInvoke = new CacheableInvocation(InvocationKind.InvokeMemberAction, "Clear");

            var tWatch = TimeIt.Go(() => tCachedInvoke.Invoke(tValue));
            var tMethodInfo = tValue.GetType().GetMethod("Clear", new Type[] { });
            var tWatch2 = TimeIt.Go(() => tMethodInfo.Invoke(tValue, new object[] { }));

            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Reflection: " + tWatch2.Elapsed);
            TestContext.WriteLine("Impromptu VS Reflection: {0:0.0} x faster", (double)tWatch2.Elapsed.Ticks / tWatch.Elapsed.Ticks);
            Assert.Less(tWatch.Elapsed, tWatch2.Elapsed);
        }
开发者ID:bbenzikry,项目名称:impromptu-interface,代码行数:17,代码来源:SpeedTest.cs


注:本文中的System.Collections.Dictionary.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。