Search code examples
c#linkeraliasscope-resolutionname-clash

C# Default scope resolution


I have inherited a c# class 'Button' (which I can't change) which clashes with the BCL class 'Windows.Forms.Button'. Normally, Id be very happy to go:

MyPackage.MyClass.Button;

But there are a large number or references to this class which is a pain to have to re-type.

Is there any way to get the compiler (linker?) to default to using the customised version of Button over the BCL version?


Solution

  • Add this to the top of the file:

    using MyButton = MyPackage.MyClass.Button;
    

    Now you can reference your custom button using a distinct name. You may need to do something similar for the stock button if you use that anywhere in the same file.