So, today I was thinking about .NET arbitrary build using ILSpy + dotPeek to get a deeper understanding of how IL code works when I stumbled upon this strange part (dummy example):
public class SomeBaseClass { public SomeBaseClass(SomeType[] iExpectACollection) { ... } } public class SomeDerivedClass { public SomeDerivedClass(SomeType onlyOneInstance) { SomeType[] collection; if(onlyOneInstance != null) collection = new SomeType[] { onlyOneInstance }; base.\u002Ector(collection); } }
As far as I can tell, the derived class does not first call the base constructor, but instead does something with onlyOneInstance and , rather , the base constructor.
My question is: is it possible to explicitly call the base constructor in C # after doing some work? Or is it possible only in IL? I know that this is easy to do, for example. Java using super() , however I never saw it in .NET.
EDIT
I just talked with my boss, and he is fine with posting some real code in the library (this is one of our internal companies):
**IL PART** .method public hidebysig specialname rtspecialname instance void .ctor ( string contextId, class MyComp.NetStack.BufferManager bufferManager, class MyComp.NetStack.TcpChannelQuotas quotas, class [System]System.Security.Cryptography.X509Certificates.X509Certificate2 clientCertificate, class [System]System.Security.Cryptography.X509Certificates.X509Certificate2[] clientCertificateChain, class [System]System.Security.Cryptography.X509Certificates.X509Certificate2 serverCertificate, class MyComp.NetStack.EndpointDescription endpoint, class MyComp.NetStack.ApplicationThreadPool threadPool ) cil managed {
source share