Search code examples
c#aliasextern

Switching Between External Aliases Without Re-Writing Code?


extern alias dll1;
extern alias dll2;    
...

public void DoStuff1(){
    dll1::NameSpace.Class.Method();
}
public void DoStuff2(){
    dll2::NameSpace.Class.Method();
}

What I'd like to be able to do is:

public void DoStuff(alias a){
    a::NameSpace.Class.Method();
}

alias does not appear to be usable like this.

Addendum: dll1 and dll2 are different versions of the same dll.


Solution

  • I ended up using dynamic in .Net 4.0.

    The combination of using external aliases with dynamic was the cleanest and simplest solution for this problem.