C# 'is' type check on struct - odd .NET 4.0 x86 optimization behavior

前端 未结 6 952
孤城傲影
孤城傲影 2021-02-02 07:20

Update: I have filed a bug report with Microsoft Connect, please vote for it!

Update 2: Microsoft have marked the bug report as fixed

6条回答
  •  悲&欢浪女
    2021-02-02 07:31

    That's not cool. I think you should file a bug. (connect.microsoft.com)

    Also, this seems to work (I only tested for your fail case though):

        public static bool IsGuid(object item)
        {
            return item.GetType() == typeof(Guid);
        }
    

提交回复
热议问题