Why is the C# compiler emitting a callvirt instruction for a GetType() method call?

前端 未结 5 1382
北荒
北荒 2020-11-30 05:40

I am curious to know why this is happening. Please read the code example below and the corresponding IL that was emitted in comments below each section:

usi         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 06:24

    As a (perhaps-)interesting aside... GetType() is unusual in that it isn't virtual - this leads to some very, very odd things.

    (marked as wiki as it is somewhat off-topic to the actual question)

提交回复
热议问题