Override Default Constructor of Partial Class with Another Partial Class

前端 未结 12 1868
时光取名叫无心
时光取名叫无心 2020-12-28 12:59

I don\'t think this is possible, but if is then I need it :)

I have a auto-generated proxy file from the wsdl.exe command line tool by Visual Studio 2008.

Th

12条回答
  •  感动是毒
    2020-12-28 13:28

    You can't do this. I suggest using a partial method which you can then create a definition for. Something like:

    public partial class MyClass{ 
    
        public MyClass(){  
            ... normal construction goes here ...
            AfterCreated(); 
        }
    
        public partial void OnCreated();
    }
    

    The rest should be pretty self explanatory.

    EDIT:

    I would also like to point out that you should be defining an interface for this service, which you can then program to, so you don't have to have references to the actual implementation. If you did this then you'd have a few other options.

提交回复
热议问题