Visual Basic hides virtual methods from C#? Not really!

I was recently asked to investigate a potential issue about the C# to Visual Basic language inter-op. The punch line was that C# could not call a method defined in a library written in Visual Basic. However, if you used C# or Visual Basic for both assemblies, everything worked as expected. The Visual Basic code used to produce…

1

Using the static type of a variable in a dynamic call

As I said before, figuring out when the compiler will dispatch a call dynamically is simple: anytime the receiver or one of the arguments of a call is dynamic. And when using a variable of type dynamic means that the Runtime Binder will use the runtime type of the value stored in that variable and…


Compile time type vs runtime type of a variable

Let’s consider this code for a moment: 1: public abstract class Animal { } 2:   3: public class Tiger : Animal { } 4:   5: public class Elephant : Animal { } 6:   7: public class MyClass 8: { 9: public static void Main() 10: { 11: Animal a = new Tiger();…

2

How-To: Dynamic without dynamic

I am sure that by now you all heard about the new C# 4.0 feature called dynamic. In short, dynamic is the new feature in C# 4.0 that allows you to defer member binding until runtime. The way you use this feature is very straight forward. If you have a class C with a method…


C# 4.0 – Dynamic internals talk

Yesterday I gave a talk to the Redmond .NET user group where I talked about the C# 4.0 dynamic feature. The talk focused on how the feature is implemented and how all the pieces go together. About 30 people showed up and stayed for the 1 hour and 40 minutes of dynamic talk. According to…


Using Anonymous types to deserialize JSON data

While I was playing around with deserializing objects written in JSON format, I noticed that I had to write a lot of classes that were used just to deserialize the JSON response. I noticed that I did not necessarily needed those classes, and that I often would just transfer data from those classes back into…

8