【发布时间】:2023-03-14 05:00:02
【问题描述】:
有没有一种方法可以判断分配给对象的类型是否是动态类型?
例如:
dynamic foo = GetCat();
Console.WriteLine( (foo is Cat).ToString() ); // will print True because
// at the execution time, foo will have assumed the Cat type. However, is
// there a mechanism by which I can reflect on foo and say, "This guy was assigned
// a dynamic type, to begin with."?
【问题讨论】:
-
我认为这是不可能的,但由于我不完全确定,我就等着看有什么答案。;)
-
出于好奇,你为什么想知道?
-
嗨,埃里克,我认为您的评论是针对卢塞罗的。但我现在怀疑它是针对我最初的问题的。我已通过您的官方电子邮件地址向您发送了一封私人电子邮件,其中包含您问题的答案。
标签: c# reflection dynamic c#-4.0