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…

0

When does the compiler dispatch a call dynamically?

There are 2 cases when a call will be dispatched dynamically: When the receiver of the call is statically typed as dynamic 1: dynamic d = new MyClass(); 2: d.Foo(); When any of the arguments to the call are statically typed as dynamic 1: var o = new MyClass(); 2: dynamic d = 4; 3:…

0

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…

0

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…

0

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

C# 4.0 language features at Seattle Code Camp

I just came back from Seattle Code Camp where I gave a talk on C# 4.0. Seattle Code Camp is a community organized event where people meet and talk about code. My presentation was about the new language features we are introducing in C# 4.0. I talked about C# dynamic, named and optional parameters and COM interop. People were very interested…

0