Why are expression trees safer than reflection?

后端 未结 4 1668
感动是毒
感动是毒 2021-02-05 11:55

In this answer to the question of the fastest way to determine if a property contains a given attribute, user Darin Dimitrov posited that expression trees are safer than reflect

4条回答
  •  悲哀的现实
    2021-02-05 12:34

    The question as it is stated is why is expression trees safer then reflection.

    The answer is that they are both using reflection.

    Edit to clarify - MemberInfo.GetCustomAttributes is a reflection call.

    http://msdn.microsoft.com/en-us/library/system.reflection.memberinfo.getcustomattributes(VS.71).aspx

提交回复
热议问题