Answer by Marc Gravell for Why is the C# compiler emitting a callvirt...
As a (perhaps-)interesting aside... GetType() is unusual in that it isn'tvirtual - this leads to some very, very odd things.(marked as wiki as it is somewhat off-topic to the actual question)
View ArticleAnswer by Gishu for Why is the C# compiler emitting a callvirt instruction...
Just playing safe.Technically C# compiler doesn't always use callvirtFor static methods & methods defined on value types, it uses call. The majority is provided via the callvirt IL instruction.The...
View ArticleAnswer by Dustin Campbell for Why is the C# compiler emitting a callvirt...
See this old blog post by Eric Gunnerson.Here's the text of the post:Why does C# always use callvirt?This question came up on an internal C# alias, and I thought the answer would be of general...
View ArticleAnswer by James Gregory for Why is the C# compiler emitting a callvirt...
I would hazard a guess that it's because the first assigns to a variable, which potentially could contain a downcasted instance of another type that could've overridden GetType (even though we can see...
View ArticleAnswer by zildjohn01 for Why is the C# compiler emitting a callvirt...
The compiler doesn't know the real type of o in the first expression, but it does know the real type in the second expression. It looks like it's only looking at one statement at a time.This is fine,...
View ArticleWhy is the C# compiler emitting a callvirt instruction for a GetType() method...
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:using System;class Program{ static void Main() {...
View Article
More Pages to Explore .....