.net - method overloading and dynamic keyword in C# -


i still haven't upgraded 4.0 else have checked code snippet myself. hope expert can comment on this.

in following code, appropriate print() method called @ runtime? legal in c# 2010 call way?

public void test() {     dynamic objx = instantiateasstringordouble();      print(objx); }  public void print(string s) {     console.write("string"); }  public void print(double n) {     console.write("double"); } 

thanks!

yes, in fact work. check usage of dynamic @ runtime , call appropriate method, lose of compile-time checking, i'd make sure that's you'd want do.


Comments